每当我输入something.com时,我的当前配置会显示app_dev.php,这是正确的,因为我当前的重写规则。但我想要的是如果用户键入www.something.com它会自动指向www.something.com/home
注意:' home'是我的一个捆绑下的路线
这是我当前的配置
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin admin@something.com
ServerName www.something.com
# Index file and Document Root (where the public files are located)
# DirectoryIndex home # I have already tried this, nothing happens
DocumentRoot /home/user/public/something.com/web/symfony/web
# Log file locations
LogLevel warn
ErrorLog /home/user/public/something.com/log/error.log
CustomLog /home/user/public/something.com/log/access.log combined
</VirtualHost>
.htaccess在Symfony / web
中<IfModule mod_rewrite.c>
RewriteRule ^$ app.php/home [L]
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
RewriteRule ^app_dev.php - [L]
RewriteRule ^app.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
RewriteRule ^(.*)$ app.php [QSA,L]
#RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>
实际网址必须是www.something.com/app.php/home(当前规则隐藏了app.php)
编辑:根据给出的答案更新.htaccess。但仍然没有工作
答案 0 :(得分:0)
答案 1 :(得分:0)
在.htaccess或VirtualHost中,使用mod_alias
获取临时重定向(302)。您不必担心它与您的应用程序URL重写冲突。
Redirect / /home