【发布时间】:2016-08-04 03:38:13
【问题描述】:
我的 .htaccess 配置有问题。我的网络服务器是 Apache2,我的网站是用 PHP 编码的。但是,我在使用 .htaccess 时遇到了一些问题。
当我通过非 SSL (http://mywebsite.dev) 访问它时,我的 .htaccess 可以正常工作。我使用 .htaccess 进行 URL 重写并通过自定义模板处理错误。但是,当我通过 SSL (https://mywebsite.dev) 访问它时,索引页面就可以工作了。但是,当我访问https://mywebsite.dev/page/about 时,它显示 404 Not Found(显示默认的 404 Not Found 页面,而不是我的自定义页面。这意味着我的 .htaccess 代码没有加载)。
对于我的 URL 结构,它是 http://mywebsite.dev/?load=page&page=about。如果我访问http://mywebsite.dev/page/about,它就可以工作。但是,不是通过 SSL。什么是问题?顺便说一句,我的 /etc/apache2/sites-available/website.conf 代码是:
<VirtualHost *:80>
ServerName mydomain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/website/
<Directory /var/www/html/website>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# enabled or disabled at a global level, it is possible to
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
而且,我的 .htaccess 代码是:
RewriteEngine On
RewriteRule ^page/([A-Za-z0-9-]+)/?$ index.php?load=page&page=$1 [NC]
ErrorDocument 404 /public/404.html
我正在使用 Laragon 在 Windows 中开发它。生产环境是:Ubuntu 16、PHP 7 和 Apache2。谢谢。
抱歉语法错误,或者你不明白我的意思。非常感谢您阅读我的问题:)
【问题讨论】:
标签: php apache .htaccess mod-rewrite ssl