.htaccess在单页面上取消屏蔽

时间:2014-11-20 10:49:51

标签: php apache .htaccess mod-rewrite

我一直在研究各种.htaccess教程和指南,将我的动态网址转换为平板搜索引擎优化网站。

除了一个链接之外,一切都运行正常,这似乎还原为动态网址。我试过禁用一些规则,但我似乎无法解决这个问题。

重定向示例

http://iforwms.com/page/home => http://iforwms.com/index.php?page=home(没问题)

http://iforwms.com/page/blog => http://iforwms.com/index.php/blog?page=blog (??)

这是我的整个.htaccess文件。希望有人可以对此有所了解......

# Set Timezone
SetEnv TZ Asia/Shanghai
Options +FollowSymLinks 

# Enable Rewriting
RewriteEngine on 

# Redirect non-www urls to www
RewriteCond %{HTTP_HOST} ^www\.iforwms\.com$ [NC]
RewriteRule ^(.*)$ http://iforwms.com/$1 [R=301,NC,L]

# Rewrite user URLs
RewriteRule ^page/(\w+)$ index.php?page=$1 [L]

# Retrieve tagged blog posts
RewriteRule ^page/blog/(\w+)$ index.php?page=blog&tag=$1 [L]

# Retrieve single blog post
RewriteRule ^page/article/(.*)/(.*)$ index.php?page=blog&article=$2 [L]

提前致谢,

-ifor

1 个答案:

答案 0 :(得分:0)

我删除了重写链接的“页面”,它以某种方式修复了问题。这是我更新的.htaccess,适用于碰巧遇到同样问题的其他人。

# Set Timezone
SetEnv TZ Asia/Shanghai
Options +FollowSymLinks 

# Enable Rewriting
RewriteEngine on 

# Redirect non-www urls to www
RewriteCond %{HTTP_HOST} ^www\.iforwms\.com$ [NC]
RewriteRule ^(.*)$ http://iforwms.com/$1 [R=301,NC,L]

# Rewrite user URLs
RewriteRule ^(\w+)$ index.php?page=$1 [L]

# Retrieve tagged blog posts
RewriteRule ^blog/(\w+)$ index.php?page=blog&tag=$1 [L]

# Retrieve single blog post
RewriteRule ^article/(.*)/(.*)$ index.php?page=blog&article=$2 [L]