[英]Why does mod_rewrite redirect to /index.php/index.php/index.php etc
I want every subdomain to act as a folder, so basicly: 我希望每个子域都充当一个文件夹,所以基本上:
projects.dev -> /
test.projects.dev -> /test
amazing-project.projects.dev -> /amazing-project
And I have this code in my Virtualhost file: 我的Virtualhost文件中有以下代码:
<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>
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). 但是,当我转到“ designs.projects.dev”时,它会重定向到“ designs.projects.dev/index.php/index.php/index.php/index.php/”(/index.php会持续一段时间)。
Does anyone know why this happens? 有谁知道为什么会这样吗?
Thanks. 谢谢。
You can use 您可以使用
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.