为什么mod_rewrite重定向到/index.php/index.php/index.php等 [英] Why does mod_rewrite redirect to /index.php/index.php/index.php etc
本文介绍了为什么mod_rewrite重定向到/index.php/index.php/index.php等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望每个子域都充当一个文件夹,所以基本上:
I want every subdomain to act as a folder, so basicly:
projects.dev -> /
test.projects.dev -> /test
amazing-project.projects.dev -> /amazing-project
我的Virtualhost文件中有以下代码:
And I have this code in my Virtualhost file:
<VirtualHost *:80>
ServerName projects.dev
DocumentRoot "D:/xampp/htdocs/projects"
ServerAlias *.projects.dev
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.projects\.dev
RewriteRule ^/(.*)$ "D:/xampp/htdocs/projects/%1/$1" [L,R=301]
</VirtualHost>
但是,当我转到"designs.projects.dev"时,它会重定向到"designs.projects.dev/index.php/index.php/index.php/index.php/"(/index.php会持续一段时间).
However when i go to "designs.projects.dev" it gets redirected to "designs.projects.dev/index.php/index.php/index.php/index.php/" (the /index.php continues for a while).
有人知道为什么会这样吗?
谢谢.
推荐答案
您可以使用
<VirtualHost *:80>
ServerName projects.dev
ServerAlias *.projects.dev
DocumentRoot "D:/xampp/htdocs/projects"
RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.projects\.dev$ [NC]
RewriteRule ^ /%1%{REQUEST_URI} [L]
</VirtualHost>
这篇关于为什么mod_rewrite重定向到/index.php/index.php/index.php等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文