I have not having any luck getting my .htaccess with mod_rewrite working. Basically all I am trying to do is remove \'www\' from \"http://www.example.com\" and \"https://ww
Or this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteCond %{HTTP_PORT} =443
RewriteRule (.*) https://%1/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule (.*) http://%1/$1 [L,R=301]
I had similar problem, this is what worked for me.
In your httpd.conf, under virtual hosts, make sure you have both:
ServerName domain.com
ServerAlias www.domain.com
BOTH in VirtualHost *:80 AND VirtualHost *:443
None of the above solutions worked for me. I'm running CentOS using per directory context for apache...no VirtualHosts or anything. Nothing I tried worked until I noticed that NameVirtualHost was on by default in my config...after turning it off everything seems to be working A-OK.
It sounds like you are saying your mod_rewrite isn't working at all. Here's a few things to try:
You said it was enabled, but the provided info:
root@s15348441:/etc/apache2/mods-available# more rewrite.load
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
Just shows it under the "mods-available" folder, which means it is installed, but not necessarily turned on. If it is enabled, it should be symlinked under the "mods-enabled" folder (you'll need to a2enmod it if it isn't there)
If it is enabled, and has been restarted, the next step would be to enable the logging feature of mod rewrite; this is an excellent tool for debugging.
Edited to add: You could move the mod rewrite to the base config. If you have access to it, it's recommended to put your config in the base section anyway (see here). It's also easier to determine if it has anything to do with mod_rewrite (like your allowoverrides are getting confused) or it's purely an htaccess problem.
Keeping on: (@Vinko Vrsalovic is right about this being a hard debugging medium) If you moved it to your base config and it still didn't work, then we're onto something, you've eliminated .htaccess portion. You should post the new config, along with the rewrite logs. If you didn't get a rewrite log, then 1) your config hasn't been loaded (need to restart apache) or 2) you aren't hitting the config section you think you are
I've had a similar problem..Mod Rewrite enabled, .htaccess permissions are correct, AllowOverride set to All but .htaccess not being read. After hours of pain and searching for an answer this is what my problem was: (hope this helps anyone)
I've had another virtual host's site enabled besides the one I was testing and it shared a common Directory root (/var/www) and AllowOverride was set to none for the other site. Solution was simply to disable the other site with "a2dissite"
I had the problem on making mod_rewrite works on my new fresh CentOS 6 installation. Nothing worked for me, until I accidentally saw that there are two AllowOverride
inside of httpd.conf. One inside <Directory />
and another one inside <Directory "/var/www/html">
. I changed both values to All and then it worked. Hope it helps somebody!
P.S. I didn't use Virtual Hosts