我过去常常使用SEO url的爆炸功能:
site.com/?/category/id/topicname/ (or site.com/index.php?/category/id/topicname/)
但是,我开始使用.htaccess
。但我现在有问题。旧的推荐人无法访问该文章。如何更改网址:
来自:site.com/?/category/id/topicname/
于:site.com/category/id/topicname/
和
来自:site.com/index.php?/category/id/topicname/
至:site.com/category/id/topicname/
编辑: 我的.htaccess文件:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
RewriteRule ^([0-9a-zA-Z-_]+)/$ index.php?modul=$1 [L,QSA]
RewriteRule ^([0-9a-zA-Z-_]+)$ index.php?modul=$1 [L,QSA]
RewriteRule ^([0-9a-zA-Z-_]+)/([0-9]+)\/?$ index.php?modul=$1&id=$2 [L,QSA]
RewriteRule ^([0-9a-zA-Z-_]+)/([0-9]+)/([0-9a-zA-Z-_]+)\/?$ index.php?modul=$1&id=$2 [L,QSA]
答案 0 :(得分:2)
将以下指令添加到.htaccess
,第一个条件断言没有先前的重定向(否则,它将是无限循环)
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteCond %{QUERY_STRING} ^/(.+)$
RewriteRule ^(index\.php)?$ /%1? [NC,R=301,L]