前段时间架了个Wordpress的博客,开始一直蛮顺利的,一直后来发现在改永久链接的时候,改后居然出现404错误。百度一下,网上说Mod_rewrite要打开,于是也就按照着网上的方法,试了很多都不是很见成效。也有说linux平台下不存在问题,于是就尝试了下ubuntu,可是依然存在问题,找找啊 ,弄 啊弄,最终还是成功了,以下是个人整理的方法,仅供我等菜鸟参考。 :)

---------------------------------------------------------------------------------------------------------

Win2003平台:

  开启Mod_rewrite模块

 

  1、打开Apache2/conf/httpd.conf

  搜索 LoadModule rewrite_module modules/mod_rewrite.so (Apache2是这个)

  去掉前面的#

 

  2、找到

  #

  # AllowOverride controls what directives may be placed in .htaccess files.

  # It can be "All", "None", or any combination of the keywords:

  # Options FileInfo AuthConfig Limit

  #

  AllowOverride None

 

  把 AllowOverride None 改为 AllowOverride All

 

  3、重启Apache

 

注意:一定要确认LoadModule rewrite_module modules/mod_rewrite.so 打开了。

 

 

Ubuntu平台:

   1、开启Apache Override

   sudo a2enmod rewrite启动了mod_rewrite模块

 

   2、修改/etc/apache2/sites-enabled下虚拟主机配置文件

   DocumentRoot /var/www/wordpress/

        <Directory />

                Options FollowSymLinks

                AllowOverride All

                RewriteEngine On

                RewriteBase /

                RewriteCond %{REQUEST_FILENAME} !-f

                RewriteCond %{REQUEST_FILENAME} !-d

                RewriteRule . /index.php [L]

        </Directory>

 

   3、重启Apache 

   /etc/init.d/apache2 restart

 

注意:一定要确认sudo a2enmod rewrite。

 

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐