仅当主机名等于“dev.local”时,我才尝试设置 RewriteBase,但我的 if 语句似乎不起作用。
虚拟主机:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName dev.local
DocumentRoot /var/www-shared
Alias /frontoffice /var/www-shared/frontoffice-laravel/public
<Directory /var/www-shared>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
访问:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
<If "%{SERVER_NAME} == 'dev.local'">
RewriteBase /frontoffice
</If>
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>