修改htaccess,将index.php重定向到folder / index.php

时间:2016-03-31 19:38:06

标签: .htaccess

以下是我目前在.htaccess文件中的内容:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

当访问者访问网站时我试图这样做:www.example.com而不是加载index.php我希望它加载folder/index.php

我在网上看到了类似RewriteRule ^index.php /folder [R=301]的内容,但这似乎无法奏效。

有没有办法做到这一点,同时保持.htaccess目前的功能。

1 个答案:

答案 0 :(得分:1)

您可以使用:

RewriteEngine On

# http => https 
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=302]

# load folder/index.php for landing page
RewriteRule ^/?$ folder/index.php [L]