FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

help with mod_rewrite

 


kv
I am new to .htaccess and mod rewrite. I need help to achieve the following.

All requests in the form

Code:
http://<subdomain>.example.com/<filename>

should be redirected to

Code:
http://example.com/<subdomain>_<filename>


except for subdomains sub1 and sub2.

what are the mod rewrite statements I have to use?
eepman
Hope this works:
Code:

RewriteEngine On
RewriteRule http://sub1.domain.com/[.*]$ http://sub1.domain.com/$1 [L]
RewriteRule http://sub2.domain.com/[.*]$ http://sub2.domain.com/$1 [L]
RewriteRule http://[.*]\.domain.com/[.*]$ http://www.domain.com/$1_$2


If it doesn't just tell me, I haven't tested it.
Stubru Freak
eepman wrote:
Hope this works:
Code:

RewriteEngine On
RewriteRule http://sub1.domain.com/[.*]$ http://sub1.domain.com/$1 [L]
RewriteRule http://sub2.domain.com/[.*]$ http://sub2.domain.com/$1 [L]
RewriteRule http://[.*]\.domain.com/[.*]$ http://www.domain.com/$1_$2


If it doesn't just tell me, I haven't tested it.


I think you should put brackets around it, isn't it?
Like this:
Code:

RewriteEngine On
RewriteRule http://sub1.domain.com/([.*])$ http://sub1.domain.com/$1 [L]
RewriteRule http://sub2.domain.com/([.*])$ http://sub2.domain.com/$1 [L]
RewriteRule http://([.*])\.domain.com/([.*])$ http://www.domain.com/$1_$2


Not sure though, also, escape your dots:
Code:

RewriteEngine On
RewriteRule http://sub1\.domain\.com/([.*])$ http://sub1.domain.com/$1 [L]
RewriteRule http://sub2\.domain\.com/([.*])$ http://sub2.domain.com/$1 [L]
RewriteRule http://([.*])\.domain\.com/([.*])$ http://www.domain.com/$1_$2
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.