Gossamer Forum
Home : General : Internet Technologies :

mod_rewrite, redirect to dynamically created pages

Quote Reply
mod_rewrite, redirect to dynamically created pages
hiya

I'm pretty new to the mod_rewrite plugin for apache and i seem to have stumbled and could do with a helping hand if possible.

I have a website where the pages are all created dynamically from a mysql database using a content management system the file structure goes like this


1) http://www.mydomain.com/cms/cms/user1/
...........................|...............\..../........\
......................Domain...........Folders.....Username


I would like the address bar to show url number 2 when someone requests that same url, but they will be redirected to the dynamic location url1 by a jsp that will be implemented as they request the page (unless anyone knows how to redirect to a dynamically created location with mod_rewrite at the same time as implmenting the rewrite rule).

So my initial question is how can i change the url using the username as the domain.

2) http://www.user1.com


thanks for any help in advance

Brad
Quote Reply
Re: [bradrob] mod_rewrite, redirect to dynamically created pages In reply to
How about:

RewriteCond %{HTTP_HOST} !maindomain.com
RewriteRule (.*) /cms/$1/${HTTP_HOST} [L]

And setup all your user domains as serveraliases for the domain with the cms on it. Then, when a user goes to:

http://user1.com/foo/

it will get rewritten to

/cms/foo/user1/

and be on the domain that the cms is installed on.

Hope that helps,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] mod_rewrite, redirect to dynamically created pages In reply to
No, i think i may have got you confussed what i want to do is take the user name and make that the domain



/cms/foo/user1
|
www.user1.com