RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com$1 [R,L]
I added RewriteLog and set the level to 9 so that everything was logged for the port 443 entry, but the log is not updated.
To reiterate, the problem is forcing https://domain.com to https://www.domain.com. I can't force www and then http to https when https is being initially connected to.
[web] Using mod_rewrite in https, not mod_rewrite to https
I've got a domain that I'm forcing www and https on. When accessing domain.com, everything is rewriting perfectly. However, the issue I'm having is to force
https://domain.com
To rewrite to
https://www.domain.com
The settings currently in place:
That bit causes a redirect loop in my SSL config settings. Exactly where do you suggest I put this?
Put it inside the non-SSL virtual host declaration. Putting it at the global level will cause the infinite redirections, like you're experiencing.
Either I'm not making my problem clear or people are glancing over what I'm describing as the problem since this is the third time a solution for port 80 was suggested when the problem is located on port 443. While the redirect can help me reduce the rewrite rules I have to force www and https (I intend on using it, thanks), I need the site to go to https://www.domain.com when https://domain.com is accessed.
Are you sure that the logfile path you set with RewriteLog is writable by Apache? Is it an absolute path? You could also `touch` the logfile yourself and chown it to the proper user.
The path to the log file is correct because I could see it populating (tail -f) as I tried accessing it on port 80 and 443. I tried throwing :443 on the end of the condition, which would trigger a redirect loop because www.domain.com != www.domain.com:443.
Quote:The path to the log file is correct because I could see it populating (tail -f) as I tried accessing it on port 80 and 443.
Ah. Your original post said that the logfile stayed empty. Could you post part of the rewrite log then please?
Well there's nothing to post when using the rewrite I have in place. Want me to add :443 and show you want it does? The current condition is not met so I have to force it to not match in order for the rewrite to apply.
Quote:Well there's nothing to post when using the rewrite I have in place.
Eh? That can't be. With RewriteLogLevel set to 9 it should take Apache well over 100 lines per request to not match a simple rule. When the Apapche guys warn you about RewriteLogLevel 3 and up being verbose enough to kill your server in a live environment, they are not kidding.
Are you sure you are looking at the file set by RewriteLog, and not the standard Apache access log or error log?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement