Mobile app version of vmapp.org
Login or Join
Si4351233

: Just another mod_rewrite question from the url xxx.yyy.site.com just need to redirect to xxx.site.com Thanks for the help, sorry I have no regex/rewrite foo.

@Si4351233

Posted in: #Apache #ModRewrite

from the url

xxx.yyy.site.com


just need to redirect to

xxx.site.com


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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si4351233

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

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

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme