我试图在Ubuntu 18.04上设置Apache服务器,我设法安装了所有内容并启用了HTTPS。
问题是当我输入漂亮的URL时,我收到此消息
未找到 在此服务器上找不到请求的URL / prettyurl。 位于example.com端口443的Apache / 2.4.29(Ubuntu)服务器
配置文件
sudo nano /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI [END,NE,R=permanent]
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3&e=$4 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&c=$2&d=$3 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ index.php?page=$1&c=$2 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?page=$1 [NC,L]
工作网址
https://example.com
https://www.example.com
https://www.example.com?page=prettyurls&id=1
http://example.com
http://www.example.com
http://example.com/prettyurls/1 (Pretty URL on HTTP working)
不工作
https://www.example.com/prettyurls/1 (Pretty URL on HTTPS NOT working)
https://example.com/prettyurls/1
错误
Not Found
The requested URL /prettyurl was not found on this server.
Apache/2.4.29 (Ubuntu) Server at example.com Port 443
出现上述错误的问题是该URL有效并且可以在HTTP上运行,但是一旦它是HTTPS,它将无法正常工作
我希望有人能帮忙