使用我当前的配置,每次我键入 something.com 时,它都会显示 app_dev.php,因为我当前的重写规则是正确的。但我想要的是,如果用户输入 www.something.com,它将自动定向到 www.something.com/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>
Symfony/web 中的 .htaccess
<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>
实际的 url 必须是 www.something.com/app.php/home (当前规则隐藏了 app.php)
编辑:根据给出的答案更新了 .htaccess 。但仍然无法正常工作