后台设置好固定链接之后,就会出现文章页面或者所有的页面都出现404错误

很多站长玩WordPress的时候,会碰到一个问题,想把WordPress伪静态,在后台设置好固定链接之后,就会出现文章页面或者所有的页面都出现404错误。解决方法如下:

  1,.htaccess要开放写权限,这样在自定义wp的永久链接时,wp会自动重写.htaccess。所谓删除或手动重写.htaccess就是因为没有开放它的写权限。

  2,找到APACHE文件中的httpd.conf文件, 把#LoadModule rewrite_module modules/mod_rewrite.so 前的#去掉,加载rewrite模块。

  3,查看APACHE文件中的httpd.conf文件是否默认设置了AllowOverRide为None,如果是,要改成All。

    或者修改 wordpress所在的vhost段添加 < Directory /wp所在路径/> AllowOverride All < /Directory> 重启apache。

  这也是Apache如何开启Mod_rewrite模块以及PHPWind伪静态的方法!

  本文转自:http://wpsite.info/archives/351


How to Fix WordPress Posts Returning 404 Error

Last updated onApril 2nd, 2013by Editorial Staff

Follow WPBeginner on YouTube

How to Fix WordPress Posts Returning 404 Error

WordPress is a powerful CMS. Sometimes a slight tweak can make your website inaccessible. However, finding a solution for any WordPress problem is extremely easy (check out how to properly ask for WordPress support and get it). In the past we have covered some of the most common problems WordPress users face. Like the internal server error or error establishing database connection. Another common problem that most WordPress users face at some point is WordPress posts returning a 404 Error. In this article we will show you how to fix WordPress posts returning 404 error.

Usually in this scenario a user can access their WordPress admin area, their blog’s main page, but when accessing a single posts they get a 404 Not found error. First of all, don’t panic most of the time your posts are still there and completely safe. This usually happens if your .htaccess file got deleted or something went wrong with the rewrite rules. What you need to do is fix your permalinks settings.

Go to Settings &raquo; Permalinks, and simply click on Save Changes button.

Update WordPress Permalinks settings

This will update your permalinks settings and flush rewrite rules. In most cases this solution fixes the WordPress posts 404 error. However, if it does not work for you, then you probably need to update your .htaccess file manually.

Login to your server using FTP, and modify the .htaccess file which is located in the same location where folders like /wp-content/ and /wp-includes/ are located. The easiest thing you can do is to temporarily make the file writeable by changing the permissions to 666. Then repeat the original solution. Don’t forget to change the permissions back to 660. You can also manually add this code in your .htaccess file:

01# BEGIN WordPress
02<IfModule mod_rewrite.c>
03RewriteEngine On
04RewriteBase /
05RewriteRule ^index\.php$ - [L]
06RewriteCond %{REQUEST_FILENAME} !-f
07RewriteCond %{REQUEST_FILENAME} !-d
08RewriteRule . /index.php [L]
09</IfModule>
10# END WordPress
Fix for Local Servers

Often designers and developers install WordPress on their computers using a local server for testing purposes. If you want to use pretty permalinks, then you need to enable the rewrite_module in the Apache configuration of your MAMP, WAMP, or XXAMP.

We have written a tutorial here on how to enable custom permalinks in WordPress local environment.

We hope this article helped you resolve posts returning 404 error in WordPress. Did this solution work for you? Do you have another solution that worked for you? Please share it in the comments below. We would like to make this article a comprehensive resource for users who run into this issue.


转载于:https://my.oschina.net/ajian2014/blog/293989

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值