【发布时间】:2012-11-13 11:18:04
【问题描述】:
旧网站:
www.example.com(默认)
新网站:
example.com(默认)
对于一种新的语言..
es.example.com
目前在旧网站上:
www.example.com/this-page.php
想要加入新网站(干净的网址):
example.com/this-page
es.example.com/esta-pagina
到目前为止,我有这个:
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteRule ^this-page/?$ this-page\.php?lang=$1
RewriteRule ^esta-pagina/?$ this-page\.php?lang=$1
** $_GET['lang'] 是在内部生成的,具体取决于是否点击了 example.com 或 es.example.com。
问题:
我怎样才能添加类似这样的重定向:
重定向 301 /this-page.php http://example.com/this-page
...这不会导致无限循环?
【问题讨论】:
-
为什么不能为评估 HTTP_HOST 的规则使用额外的 RewriteCond?
-
@arkascha 我是一个重写假人 - 你能告诉我如何做到这一点吗?
标签: .htaccess redirect rewrite