【问题标题】:.htaccess unmasked on single page.htaccess 在单页上未屏蔽
【发布时间】:2014-11-20 10:49:50
【问题描述】:

我一直在研究各种 .htaccess 教程和指南,以将我的动态 URL 转换为平面 SEO 友好的 URL。

一切正常,除了一个链接,它似乎恢复为动态 URL。我尝试禁用一些规则,但似乎无法解决问题。

重定向示例

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

【问题讨论】:

  • 你在/blog/ 中也有一个.htaccess 吗?

标签: php apache .htaccess mod-rewrite


【解决方案1】:

我删除了重写链接的“页面”,它以某种方式解决了问题。这是我更新的 .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]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-10
    相关资源
    最近更新 更多