Apache .htaccess 和 Zend Rewrite 与重定向冲突
我正在使用此 .htaccess 代码将旧域重定向到新域:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} test.domain.eu(.*)
RewriteRule (.*) http://test.domain.be/$1 [R=301,L]
这也适用于子目录。但在目录 /project 中,有一个带有以下 .htaccess 的 Zend 项目:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
当我转到旧域上的该目录时,重定向不起作用。所以我猜测这两个 .htaccess 文件彼此冲突。有谁知道如何进行这项工作?
I'm using this .htaccess code to redirect the old domain to the new domain:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} test.domain.eu(.*)
RewriteRule (.*) http://test.domain.be/$1 [R=301,L]
This works, also for subdirectories. But in the directory /project, there's a Zend project with the following .htaccess:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
When I go that directory on the old domain, the redirect doesn't work. So I'm guessing these 2 .htaccess files conflict eachother. Does anyone have an idea how to make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将以下 2 条规则添加
到
/project
的 .htaccess 中。礼貌:@
TerryE
。即
/folder/folder1/folder2
是请求的 URI,假设它们都有.htaccess
那么,folder2 的.htaccess
只会被使用。/folder/folder1/folder2
是请求的 URI,假设只有folder1
有.htaccess
,那么,folder1 的.htaccess
只会被使用。所以,这样做:
Add these 2 rules:
to
/project
's .htaccess as well.Courtesy: @
TerryE
.i.e.
/folder/folder1/folder2
is the requested URI, and lets say all of them has.htaccess
then, folder2's.htaccess
will only be used./folder/folder1/folder2
is the requested URI, and lets say onlyfolder1
has a.htaccess
then, folder1's.htaccess
will only be used.So, do this: