Apache vhost重定向上的双斜杠
我试图在一个Laravel应用程序中,通过反向代理通过ApacheVHost重定向强制FQDN和HTTPS。我现在的问题是,用户有时会被重定向到带有双斜杠的URL,例如Apache vhost重定向上的双斜杠,apache,redirect,mod-rewrite,https,vhosts,Apache,Redirect,Mod Rewrite,Https,Vhosts,我试图在一个Laravel应用程序中,通过反向代理通过ApacheVHost重定向强制FQDN和HTTPS。我现在的问题是,用户有时会被重定向到带有双斜杠的URL,例如https://exampledomain.xy//test而不是https://exampledomain.xy/test我不知道为什么 以下是我的apache vhost配置: <VirtualHost *:80> ServerName localhost ServerAdmin webmaster@local
https://exampledomain.xy//test
而不是https://exampledomain.xy/test
我不知道为什么
以下是我的apache vhost配置:
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
<Directory /var/www/html>
AllowOverride All
</Directory>
ErrorLog /dev/stderr
TransferLog /dev/stdout
RewriteEngine on
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} !=127.0.0.1
RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteCond %{REMOTE_ADDR} !=::1
RewriteRule (.*) https://exampledomain.xy/$1 [L,R=301]
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www/html/public"
ServerName exampledomain.xy
</VirtualHost>
服务器名本地主机
服务器管理员webmaster@localhost
DocumentRoot/var/www/html/public
允许超越所有
ErrorLog/dev/stderr
TransferLog/dev/stdout
重新启动发动机
重写cond%{HTTP_HOST}=本地服务器
重写cond%{HTTP_HOST}=127.0.0.1
重写cond%{REMOTE_ADDR}=127.0.0.1
RewriteCond%{REMOTE_ADDR}!=::1.
重写规则(.*)https://exampledomain.xy/$1[L,R=301]
服务器管理员webmaster@localhost
DocumentRoot“/var/www/html/public”
ServerName示例域.xy
和my.htaccess文件(Laravel附带的默认.htaccess文件)
选项-多视图
重新启动发动机
#如果不是文件夹,则重定向尾部斜杠。。。
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)/$/$1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
#句柄授权头
RewriteCond%{HTTP:Authorization}。
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
好的,看来我解决了这个问题。我在配置中更改了以下内容:
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://stk-support.ukl.uni-freiburg.de$1 [R=301,L]
重写规则中的额外斜杠导致了这个问题,我还添加了一个HTTPS重写条件
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://stk-support.ukl.uni-freiburg.de$1 [R=301,L]