所以,我试图做到这一点:
So, I'm trying to accomplish this:
我们有一个网址 /brand/new-inventory.php
。这是我们的网站内的物理文件。
我想它会是 /品牌/新
。现在,这很简单。所有我不得不添加了重写规则^品牌/新$品牌/新inventory.php [L,QSA]
。
We have a URL /brand/new-inventory.php
. This is a physical file within our site.
What I'd like it to be is /brand/new
. Now that was easy. All I had to add was RewriteRule ^brand/new$ brand/new-inventory.php [L,QSA]
.
现在,我想获得的设置,我一直在挣扎是这样的:
Now, what I'd like to get setup and I've been struggling with is this:
我们需要 /brand/new-inventory.php
有人看重定向到 /品牌/新
所以我们有一致的网址和什么,而不是。
We need /brand/new-inventory.php
when viewed by someone to redirect to /brand/new
so we have consistent URL's and what-not.
但是,当我尝试重写规则^品牌/新inventory.php $品牌/新[R = 301,L]
火狐开始抱怨重定向循环永远不会结束。
But, when I try RewriteRule ^brand/new-inventory.php$ brand/new [R=301,L]
Firefox starts to complain about a redirect loop that will never end.
我如何重写一个页面来应对不同的URL,并重定向旧的URL到新的?
How can I rewrite a page to respond to a different URL, and redirect the old URL to the new one?
有这样说道:
RewriteCond %{THE_REQUEST} s/+brand/new-inventory.php[/s?] [NC]
RewriteRule ^ /brand/new [R=302,L]
RewriteRule ^brand/new$ /brand/new-inventory.php [L,NC]
不同的是使用%{THE_REQUEST}
收到被Apache重新presents原始请求从您的浏览器。这个变量的值不与应用程序的其他重写规则的改变。
Difference is use of %{THE_REQUEST}
that represents original request received by Apache from your browser. Value of this variable doesn't change with application of other rewrite rules.