from the url


just need to redirect to


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


This rule will redirect (301 Permanent Redirect) all incoming requests to xxx.yyy.site.com domain to http://xxx.site.com/ preserving the URL path (e.g. http://xxx.yyy.site.com/kitten?say=meow will be redirected to http://xxx.site.com/kitten?say=meow:

RewriteEngine On

RewriteCond %{HTTP_HOST} =xxx.yyy.site.com
RewriteRule .* http://xxx.site.com%{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).

  • Thank you for your response. Much appreciated, was having a bit of an issue at work. Aug 20 '11 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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