Help for custom Apache rule or .htaccess

RickDeckard

Verified User
Joined
Mar 18, 2011
Messages
103
Hi, i need help for create a rule on Apache or a custom .htaccess to redirect any link like:

subxxx.domain.com

to

sub.domain.com/subxxx

Any suggestions? :confused:

Thanks!
 
Hello,

1. php script with header() redirect
2. html page with meta/javascript redirect
3. mod_rewrite
4. apache native redirect

choose any of these and search forums/internet for details.
 
Thanks for your reply, so something like

PHP:
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.net$
RewriteCond %{HTTP_HOST} !^www.example.net$
RewriteCond %{HTTP_HOST} !^example.net$
RewriteRule ^/(.*)$ http://www.example.net/%1/$1 [R=301,L]
 
Last edited:
Now it's working adding this as virtual host custom rule:

PHP:
|*if SUB="zzzz"|
    ServerAlias *.|DOMAIN|
    RewriteCond %{HTTP_HOST} ^(.*)\.|DOMAIN|          
    RewriteRule ^/(.*)$ https://www.anotherdomain.tld/%1$1 [L,NC,QSA]  
|*endif|
 
Last edited:
Back
Top