【发布时间】:2016-03-31 20:43:16
【问题描述】:
我正在使用 AWS EC2 实例来托管网站。我在 /var/www/html/xyz/ 目录下进行了安装,因此如果我必须访问网站主页,我必须将链接指定为 www.example.come/xyz。我希望 www.example.com 应该被重定向到 www.example.com/xyz
知道如何自动将 www.example.com 重定向到 www.example.com/xyz(httpd 配置或类似的东西)?
我在网上查过,但大多数帖子都与子域重定向有关,例如将 admin.example.com 重定向到 www.example.com,这不是我的问题。
谢谢!
我的 .htaccess 文件是:
<IfModule mod_rewrite.c>
RewriteEngine on
# Some hostings require RewriteBase to be uncommented
# Example:
# Your url is http://www.yourcompany.com/xyz
# So "RewriteBase" should be:
# RewriteBase /xyz
Options -MultiViews
RewriteBase /xyz
RewriteCond %{REQUEST_URI} ^api/(.*)$ [or]
RewriteCond %{REQUEST_URI} .*/api/(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*api/(.*)$ api.php?_d=$1 [L,QSA]
RewriteCond %{REQUEST_URI} \.(png|gif|ico|swf|jpe?g|js|css|ttf|svg|eot|woff|yml|xml)$ [or]
RewriteCond %{REQUEST_URI} store_closed.html$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?)\/(.*)$ $2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,QSA]
</IfModule>
【问题讨论】:
标签: php apache .htaccess redirect amazon-ec2