我有一个简单的.htaccess文件,该文件在网站的http版本上效果很好,但是当我转到https时却不行。 为什么?
RewriteEngine on #This is so if the file exists then use the file RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ %{REQUEST_FILENAME} [L] #These conditions check if a file or folder exists just for reference #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #if someone adds ".php" to the slug get rid of it RewriteRule ^(.*)\.php$ $1 #don't add the [R] here because we don't want it to redirect RewriteRule ^(.*)$ index.php?id=$1 [L,QSA]
这里没有足够的信息可以继续,但是在通常的默认SSL设置(Red Hat / CentOS / Fedora)中,VirtualHost for SSL被设置在它自己的容器中。 使用mod_rewrite至less需要在文档根目录上设置“AllowOverride FileInfo”以使其起作用。
检查您的configurationSSL(默认情况下/etc/httpd/conf.d/ssl.conf),确保它看起来像这样:
DocumentRoot /var/www/html <Directory /var/www/html> AllowOverride FileInfo </Directory>
AllowOverride的默认值是'None',所以添加FileInfofunction的任何其他设置(例如'All')都可以。
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
有没有可能,mod_rewrite没有启用HTTPS服务器,或.htaccess没有被使用?
检查常规站点的AllowOveride权限,并与SSL版本进行比较,可能是差异。 如果不是偶然发生的话,大概介绍一下可以提高安全性。
mod_rewrite是必不可less的,所以任何体面的主机提供商应该帮助解决这个问题。
“工作在apache2 + ubuntu精确”
当我使用Slim框架并尝试删除url中所需的index.php时,发生了类似的问题。 reWrite对于http完美工作,但对于https:它显示的url没有find,这意味着reWrite不起作用。
经过一番打击后,我想出了这个解决scheme:
cd /etc/apache2/sites-enabled sudo vim default-ssl
将AllowOverride None更改为全部 。 同样的sudo vim ssl