Forum Moderators: phranque

Message Too Old, No Replies

Subdomains and pages ReWrite Rules

MAKE http://somesub.mydomain.com/filename --> point to script

         

OnlyJC

12:52 pm on Nov 10, 2005 (gmt 0)

10+ Year Member


Hello

What I want is:

Some one types
http://www.[sub].mydomain.com/pagename.php

Internal redirect to:

http://www.mydomain.com/script.php?uid=[sub]&page=pagename.php

So far I've got the sub domain part to work. This is my rewrite so far:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.([a-z0-9]+)\..+\..*$ [NC]
RewriteRule ^(.*)$ /home/siteid/public_html/script.php?uid=%1&page=%2
ErrorDocument 404 /index.php

What else do I need to capture the filename aswell? I'm a bit stuck now.

jdMorgan

3:59 pm on Nov 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Correct the back-reference in the RewriteRule:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.([a-z0-9]+)\..+\. [NC]
RewriteRule ^(.*)$ /home/siteid/public_html/script.php?uid=%1&page=[b]$1[/b]

For more information, look for the term "back reference" in the Apache documentation cited in our forum charter [webmasterworld.com] and see the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com] for examples.

Jim

OnlyJC

6:56 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



Thank you

I really didn't know what it was called so I couldn't research it any further.