Mod_Rewrite Dynamic Pages

New to mod_rewrite? This is a good place to start.

Mod_Rewrite Dynamic Pages

Postby Bradrob » Wed Jan 07, 2004 2:07 am

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 with mod_rewrite) so my question is how can i change the url using the username as the domain.

2) http://www.user1.com


that is unless anyone knows how to redirect to a dynamic location using rewrite at the same time as implementing the rewrite rule.

thanks for any help in advance

cheers
Brad
Bradrob
 

Re: Mod_Rewrite Dynamic Pages

Postby iiinetworks » Sat Jan 10, 2004 3:43 am

Bradrob wrote:(unless anyone knows how to redirect with mod_rewrite)
You redirect by adding [R] to the end of your RewriteRule. However, you might want to check and make sure that your definition of Redirect is the same as the one that mod_rewrite uses.

You won't be able to make http://www.mydomain.com/cms/cms/user1/ appear as http://www.user1.com in the browser unless you own the domain www.user1.com. Otherwise, the browser will try to connect to www.user1.com which is probably something other than your site. Or am I just missing what you want to do?

Hth,
Matt
iiinetworks
 
Posts: 8
Joined: Sat Oct 11, 2003 11:53 am

Postby kadnan » Tue Mar 09, 2004 3:47 am

how can i make something like

http://user.domain.com

I want that when someone writes http://user1.domain.com it calls file

http://domain.com/file.php?id=user1

or
http://user2.domain.com calls

http://domain.com/file.php?id=user2

Kindly help me out
kadnan
 
Posts: 1
Joined: Tue Mar 09, 2004 2:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 19 guests

cron