对于301重定向重写规则条件 [英] RewriteRule conditions for 301 redirect
本文介绍了对于301重定向重写规则条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网址,这是会影响到几十个网页的重新命名部分:
I have to re-name part of a URL, which is going to affect dozens of web pages:
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]
但我读过<一个href="http://stackoverflow.com/questions/12824633/301-redirect-conflicting-with-rewriterule/12828762#12828762">RewriteRule可以交锋,该我用的.htaccess:
But I've read that RewriteRule can clash, which I'm using in .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>
所以,我有两个问题:是重写规则正确的;而我要去经历某种形式的冲突?
So, I have two questions: is the RewriteRule correct; and am I going to experience a clash of some kind?
推荐答案
将略低于 RewriteEngine叙述你的
行: 301
规则在
Place your 301
rule just below RewriteEngine On
line:
<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>
这篇关于对于301重定向重写规则条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文