技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页Apache>正文
linux下WordPress apache伪静态规则设置
2012年02月01日 Apache 暂无评论 ⁄ 被围观 23,590次+


1、首先确定Apache是否加载了Mod_rewrite 模块
方法: 检查 /etc/httpd/conf/httpd.conf 中是否存在以下两段代码 (具体路径可能会有所不同,但形式基本是一样的):
(一)LoadModule rewrite_module libexec/mod_rewrite.so
(二)AddModule mod_rewrite.c
2、检查Apache是否开启.htaccess支持
vi  /etc/httpd/conf/httpd.conf  
AllowOverride All   #如果后面参数为None需要修改为All(大概在338行)
3、在文件/etc/httpd/conf/httpd.conf相应的主机目录配置中加入如下代码(此时须注意,如果网站是通过虚拟主机来定义,请务必加到虚拟主机配置中去,否则可能无法使用。)


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


系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接
例如:

vi /etc/httpd/conf/httpd.conf  #编辑
<Directory "/var/www/html">
    Options Includes ExecCGI FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
</Directory>
4、重启Apache
/etc/init.d/httpd restart
    
5、设置WordPress
系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接
在WordPress后台-设置-固定链接-自定义结构,输入下面的代码,最后保存更改即可。        
/archives/%post_id%.html


6、配置完成
     前台打开页面类似于:http://www.osyunwei.com/archives/2034.html

     

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2024 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3