Laravel Apache2 Https 没有漂亮的 URL
我在新服务器上安装了 laravel,使用 certbot 安装了新的 HTTPS 证书,但漂亮的 url 不起作用。
通过HTTP没有问题,但是一旦我访问HTTPS,mod_rewrite似乎不起作用
这是apache HTTP配置
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mydomain.it
DocumentRoot /var/www/example-app/public
<Directory /var/www/example-app/public>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Questa la configurazione HTTPS:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName mydomain.it
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example-app/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
<Directory /var/www/example-app/public>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.it/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.it/privkey.pem
</VirtualHost>
</IfModule>
我还附加了htaccess,但它是laravel的默认值:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I installed laravel on a new server, with certbot I installed a new HTTPS certificate but the pretty urls don't work.
Via HTTP there are no problems, but as soon as I access HTTPS it seems that mod_rewrite does not work
This is the apache HTTP configuration
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mydomain.it
DocumentRoot /var/www/example-app/public
<Directory /var/www/example-app/public>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Questa la configurazione HTTPS:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName mydomain.it
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example-app/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
<Directory /var/www/example-app/public>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.it/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.it/privkey.pem
</VirtualHost>
</IfModule>
I also attach htaccess but it is the default of laravel:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改 VirtualHost 中的默认 ssl 配置文件解决问题:
Change the default ssl configuration file in VirtualHost resolve the problem: