我必须重新命名URL的一部分,这会影响几十个网页:
http://www.example.com/old/web-page至http://www.example.com/new/web-page
到目前为止,我有:
RewriteRule old/(.*) http://www.example.com/new/$1 [R=301,L]
但我已经读过RewriteRule can clash,我正在使用.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
所以,我有两个问题:RewriteRule是否正确;我是否会遇到某种冲突?
答案 0 :(得分:1)
将301
规则放在RewriteEngine On
行下面
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule old(/.*)?$ /new$1 [R=301,L,NC]
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>