I want to redirect An开发者_Go百科ything.com/xxx to Anything.com using serverAlias.
Thanks Jean
If you mean redirecting the literal path /xxx to /, you can just use a RedirectPermanent directive. Note: this will also redirect urls like /xxx2 to /2 and /xxx/yyy to //yyy.
RedirectPermanent /xxx http://Anything.com
If you are looking for something fancier like only redirecting the literal /xxx or even redirecting any path under Anything.com to http://Anything.com/ you will need mod_rewrite. This redirects only /xxx to /:
RewriteEngine On
RewriteRule ^/xxx$ /
If instead, you really want to squash all paths under the site to /, try this:
RewriteEngine On
RewriteRule ^/..*$ /
This makes any URL containing at least one character after the / to map to /. Full docs are here: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
精彩评论