Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

from the url 

just need to redirect to

Thanks for the help, sorry I have no regex/rewrite foo.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

This rule will redirect (301 Permanent Redirect) all incoming requests to domain to preserving the URL path (e.g. will be redirected to

RewriteEngine On

RewriteCond %{HTTP_HOST}
RewriteRule .*{REQUEST_URI} [R=301,L]

This rule does not take into consideration HTTPS -- it will always redirect to HTTP. If it needs to preserve protocol as well (http -> http and https -> https), then you will need to have 2 rules (one for each protocol) and one extra rewrite condition for each rule (which will take protocol into consideration).

share|improve this answer
Thank you for your response. Much appreciated, was having a bit of an issue at work. – Orbit Aug 20 '11 at 14:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.