Apache htaccess表达式工作不正常
我试图仅在主机名等于“dev.local”时设置RewriteBase,但我的if语句似乎不起作用 vhost:Apache htaccess表达式工作不正常,apache,apache2.4,Apache,Apache2.4,我试图仅在主机名等于“dev.local”时设置RewriteBase,但我的if语句似乎不起作用 vhost: <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName dev.local DocumentRoot /var/www-shared Alias /frontoffice /var/www-shared/frontoffice-laravel/public &l
<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>
服务器管理员webmaster@localhost
ServerName dev.local
DocumentRoot/var/www共享
别名/frontoffice/var/www-shared/frontoffice-laravel/public
选项-索引+FollowSymLinks+多视图
允许超越所有
要求所有授权
htaccess:
<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>
选项-多视图
重新启动发动机
后勤基地/前线办公室
#重定向尾部斜杠。。。
重写规则^(.*)/$/$1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
RewriteBase
仅在目录上下文中起作用。我的意思是,在这种情况下,如果指令打破了重写指令的顺序,那么指令就起作用。我不确定您的意思是什么。当我取出If语句时,它可以正常工作。Apache指令的执行顺序可能与配置中列出的不同。因此,RewriteBase
withif
可以在RewriteEngine On
行之前或在所有重写之后执行。