使用modrewrite模块重写wordpress链接

本文运行环境为ubuntu下root用户
1.加载mod_rewrite模块
命令

 
 
a2enmod

程序将显示可供加载的模块,输入:

 
 
rewrite

apache服务器将会自动加载mod_rewrite模块
2.修改网站配置文件
命令

cd /etc/apache2/sites-enabled/000-default

<Directory /home/yoursiteDirectory>
<div>Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all</div>
<div></Directory>[

中的AllowOverride None修改为AllowOverride All
3.直接在上述<Directory>内增加代码

RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]

即可实现链接的重写
亦可在.htaccess内使用下列代码

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
 </IfModule>

4.重新加载apache服务器配置

/etc/init.d/apache2 reload

 

或者

/etc/init.d/apache2 restart

即可成功进行链接重写

注:
在apache官方文档中建议尽量将在.htaccess能实现的功能方法放在<Directory></Directory>内
因为使用.htaccess会降低apache服务器的性能


不知为什么csdn排版总是怪怪的...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值