Forum Moderators: phranque

Message Too Old, No Replies

Modifying Rewrite Script

         

littlespy

4:17 pm on Apr 27, 2009 (gmt 0)

10+ Year Member



Hi all I have a mod_rewrite script I got off here a few months ago that will forward sub-domains like so:

[test.example.com...] -> http://www.example.com/sd_test

I'm trying to modify it, but I can't figure it out I'm not very good with regex. What I want is:

[test.example.com...] -> http://www.example.com/multisites/test

Here is the script I am using, if anyone could tell me how to make this quick fix I'll buy you a beer. :D Here is the script:


Options +FollowSymLinks

RewriteEngine on

# Canonicalize all requested hostnames
RewriteCond www>%{HTTP_HOST} ^(www)>example\.co\.uk [OR]
RewriteCond %{HTTP_HOST} ^(www)\.example\.co\.uk\. [OR]
RewriteCond %{HTTP_HOST} ^(www)\.example\.co\.uk:[0-9] [OR]
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.(www\.)?example\.co\.uk [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.?example\.co\.uk
RewriteRule (.*) http://%1.example.co.uk/$1 [R=301,L]
#
# Externally redirect direct client requests for www.example.com/sd_xyz to xyz.example.com
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /sd_[^/]+/
RewriteRule ^sd_([^/]+)/(.*)$ http://$1.example.co.uk/$2 [R=301,L]
#
# Internally rewrite xyz.example.com to filepath example.com/sd_xyz, except for "www.example.com"
RewriteCond $1 !^sd_
RewriteCond %{HTTP_HOST} !^www\.example\.co\.uk
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.co\.uk
RewriteRule (.*) /var/www/example.co.uk/public/sd_%1/$1 [L]

jdMorgan

4:29 pm on Apr 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Replace *all* instances of "sd_" in the original code with "multisites/"

Jim