Jump to content
  • Advertisement
Sign in to follow this  
Mathachew

[web] Using mod_rewrite in https, not mod_rewrite to https

This topic is 3625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
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.

Share this post


Link to post
Share on other sites
Advertisement
Put it inside the non-SSL virtual host declaration. Putting it at the global level will cause the infinite redirections, like you're experiencing.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!