I have a simple .htaccess file that works great on the http version of the site but not when I go to https. Why?
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]
There's not 100% enough info here to go on, but in the usual default SSL setup (Red Hat/CentOS/Fedora e.g.) the VirtualHost for SSL is set up in it's own container. The use of mod_rewrite requires at a minimum "AllowOverride FileInfo" to be set on the document root for it to act.
Check your config for SSL (/etc/httpd/conf.d/ssl.conf by default), ensure that it looks something like:
The default for AllowOverride is 'None', so any other setting (such as 'All') which adds FileInfo capabilities is OK.
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
Could it be possible that mod_rewrite is not enabled for the HTTPS server, or that the .htaccess is not being used?
Check the
AllowOveride
permissions in use for the regular site and compare against the SSL version, probably a discrepancy. Probably introduced to improve security, if not an accident.mod_rewrite
is next to essential though, so any decent hosting provider should help sort this out."working on apache2 + ubuntu precise"
A similar problem occured to me while I was using Slim framework and trying to remove the index.php required in the url. The reWrite worked perfectly for http but for https: it was showing url not found, which meant that the reWrite was not working.
After some hit-n-trial , I came up with this solution:
Change AllowOverride None to All. Similarly sudo vim ssl
I had similar problem, this is what worked for me.
In your httpd.conf, make sure you have both:
ServerName domain.com
ServerAlias www.domain.com