[英].htaccess redirect to index.php from root of the site
The problem is that I need to be redirected to projects.test.net/rr/index.php if I come to the root of the site which is http://projects.test.net/rr/ 问题是,如果我进入站点的根目录http://projects.test.net/rr/ ,则需要将我重定向到projects.test.net/rr/index.php。
Why the first rewrite rule isn't working? 为什么第一个重写规则不起作用? I also tried adding
我也尝试添加
RewriteCond %{HTTP_HOST}^projects.pepperit.net/rr/ [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
But it's not working. 但这不起作用。 The whole file is here:
整个文件在这里:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST}^projects.test.net/rr/$ [NC]
RewriteRule ^(.*)$http://projects.test.net/rr/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Adding DirectoryIndex fixed the problem. 添加DirectoryIndex解决了该问题。
Options +FollowSymLinks
RewriteEngine on
DirectoryIndex index.php
RewriteCond %{HTTP_HOST}^projects.test.net/rr/$ [NC]
RewriteRule ^(.*)$http://projects.test.net/rr/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
The common setting in your server can be a lot, but you want to use index.php that you can set using DirectoryIndex 服务器中的常用设置可能很多,但是您希望使用可以使用DirectoryIndex设置的index.php
Options +FollowSymLinks
RewriteEngine on
DirectoryIndex index.php
RewriteCond %{HTTP_HOST}^projects.test.net/rr/$ [NC]
RewriteRule ^(.*)$http://projects.test.net/rr/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.