Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
RewriteCond %{HTTP_HOST} ^(.*\.)*$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$$1 [R]   

Is what I have been using. It works as long as I go to a specific page, like But if you try to go to the root of the subdomain, it adds the extra "/example" at the end.

Any suggestion on a set of rules that will work?

Thank you so much for your responces!

Actually, this is what I am trying to do: >>

AND(!)* >>*

> RewriteCond %{HTTPS} off RewriteRule (.*)
> https://%{HTTP_HOST}%{REQUEST_URI}

Works, except I need it to only do it for the

With the above set up, you get a certificate warning if you try to go just, which I do not have or need an SSL certificate installed on.


The other issue with the rule I have written above, is that if you try to go to the root of the subdomain (i.e. it goes to

This is driving me crazy, help! =)

Any help would be greatly appreciated!

share|improve this question

migrated from Dec 14 '12 at 9:09

This question came from our site for professional and enthusiast programmers.

Rules that will work for what purpose? It's unclear exactly what you want your rules to do, particularly since you say they aren't doing what you want right now. – Greg Hewgill Dec 13 '12 at 22:37
Hi Zac! Please register your account on Stack Overflow, then come back and log in here. This will associate your account with this question so you can edit it and leave comments again and don't have to resort to posting "answers" as follow up questions. Cheers! – slhck Dec 14 '12 at 16:31
It doesnt look like it associated it with my account...? – Zac Cleaves Dec 14 '12 at 17:30
Oh wait there it goes. Man... this is driving me crazy. If someone can help me fix this I would be most grateful! – Zac Cleaves Dec 14 '12 at 17:31

Based on your code I'm assuming you want to do the following redirections: -> ->

And that the latter does not work.

I would rewrite in two different RewriteRule pieces.

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$$1 [L]

RewriteCond %{HTTP_HOST} ^(.+\.)$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$$1 [R]
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .