Jump to content

Url Conversion


yoursanjay

Recommended Posts

Hello,I have developed a program in PHP & MySQL and there is a membership section. After the member login the page goes to http://www.mydomain.com/member.php . All the functions are working properly. In my membership program user name of every user is unique. The issue is that at this moment I wish to show the URL of the member page after login as follows:http://www.mydomain.com/bluebell/member.php .Here bluebell is the user name. So, the main thing I need that the member.php page will be shown after the respective member's user name (/member/) in the URL. Is there any procedure that the member.php page wiil open but in the URL the above format will be shown. As, the full project has already been completed and I am very confused if I have to change the codes a lot or not. I am not familiar with MOD rewrite function.Please suggest and if possible provide me a sample code of this type URL conversion. Thanks...

Link to comment
Share on other sites

mod_rewrite is what you use. Something like (not tested):

RewriteRule ^/(.*?)/member.php$ member.php?name=$1

Link to comment
Share on other sites

... and if you have IIS7, read the RewriteModule documentation. Note that it is for IIS7 (Windows Vista, 7, Server 2008; no earlier), and you must actually download it.

Link to comment
Share on other sites

I have a hosting service that points my root web directory to:d:\inetpub\iribbit\Before they installed the mod rewrite (this is a windows box) I had to write server side scripting (and had to accept the folder being visible in the URL - i.e. http://www.iribbit.net/i/) to manage multiple domains I had configured to point to my hosting plan. I won't get into how that worked, unless asked, rather I'd like to share the script I use now, using mod rewrite functionality.This should help with the original request made in this post. In the following code you'll see how I've handled multiple domains - pointing them to their respective folders that I've defined in my root directory.

###################################### last modified 2010/01/11 - DTV #######################################RewriteEngine OnOptions +FollowSymlinksRewriteBase /#Rewrite Rule for www.iribbit.netRewriteCond %{HTTP_HOST} www.iribbit.net$RewriteCond %{REQUEST_URI} !i/RewriteRule ^(.*)$ i/$1######################### SUB/TEST DOMAINS #########################Rewrite Rule for allurephotography.iribbit.netRewriteCond %{HTTP_HOST} allurephotography.iribbit.net$RewriteCond %{REQUEST_URI} !registry/RewriteRule ^(.*)$ registry/$1#Rewrite Rule for electroelf.iribbit.netRewriteCond %{HTTP_HOST} electroelf.iribbit.net$RewriteCond %{REQUEST_URI} !electroelf/RewriteRule ^(.*)$ electroelf/$1#Rewrite Rule for weddingdayart.iribbit.netRewriteCond %{HTTP_HOST} weddingdayart.iribbit.net$RewriteCond %{REQUEST_URI} !registry/RewriteRule ^(.*)$ registry/$1#Rewrite Rule for wesmeregrove.iribbit.netRewriteCond %{HTTP_HOST} wesmeregrove.iribbit.net$RewriteCond %{REQUEST_URI} !wg/RewriteRule ^(.*)$ wg/$1#Rewrite Rule for zrii.iribbit.netRewriteCond %{HTTP_HOST} zrii.iribbit.net$RewriteCond %{REQUEST_URI} !zrii/RewriteRule ^(.*)$ zrii/$1####################### PARENT DOMAINS #######################RewriteCond %{HTTP_HOST} ^1lifeservers.com [NC]RewriteRule ^(.*)$ [url="http://www.1lifeservers.com/$1"]http://www.1lifeservers.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} 1lifeservers.comRewriteCond %{REQUEST_URI} !1lifeservers/RewriteRule ^(.*)$ 1lifeservers/$1 [L]#RewriteCond %{HTTP_HOST} ^birthingdoneright.com [NC]RewriteRule ^(.*)$ [url="http://www.birthingdoneright.com/$1"]http://www.birthingdoneright.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} birthingdoneright.comRewriteCond %{REQUEST_URI} !birthingdoneright/RewriteRule ^(.*)$ birthingdoneright/$1 [L]#RewriteCond %{HTTP_HOST} ^chaptersinlife.com [NC]RewriteRule ^(.*)$ [url="http://www.chaptersinlife.com/$1"]http://www.chaptersinlife.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} chaptersinlife.comRewriteCond %{REQUEST_URI} !chaptersinlife/RewriteRule ^(.*)$ chaptersinlife/$1 [L]#RewriteCond %{HTTP_HOST} ^chaptersinlife.net [NC]RewriteRule ^(.*)$ [url="http://www.chaptersinlife.net/$1"]http://www.chaptersinlife.net/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} chaptersinlife.netRewriteCond %{REQUEST_URI} !chaptersinlife/RewriteRule ^(.*)$ chaptersinlife/$1 [L]#RewriteCond %{HTTP_HOST} ^corvettecollection.com [NC]RewriteRule ^(.*)$ [url="http://www.corvettecollection.com/$1"]http://www.corvettecollection.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} corvettecollection.comRewriteCond %{REQUEST_URI} !corvettecollection/RewriteRule ^(.*)$ corvettecollection/$1 [L]#RewriteCond %{HTTP_HOST} ^deepcreekcam.com [NC]RewriteRule ^(.*)$ [url="http://www.deepcreekcam.com/$1"]http://www.deepcreekcam.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} deepcreekcam.comRewriteCond %{REQUEST_URI} !deepcreekcam/RewriteRule ^(.*)$ deepcreekcam/$1 [L]#RewriteCond %{HTTP_HOST} ^deepcreekcommunity.com [NC]RewriteRule ^(.*)$ [url="http://www.deepcreekcommunity.com/$1"]http://www.deepcreekcommunity.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} deepcreekcommunity.comRewriteCond %{REQUEST_URI} !deepcreekcommunity/RewriteRule ^(.*)$ deepcreekcommunity/$1 [L]#RewriteCond %{HTTP_HOST} ^deepcreeklakeside.com [NC]RewriteRule ^(.*)$ [url="http://www.deepcreeklakeside.com/$1"]http://www.deepcreeklakeside.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} deepcreeklakeside.comRewriteCond %{REQUEST_URI} !deepcreeklakeside/RewriteRule ^(.*)$ deepcreeklakeside/$1 [L]#RewriteCond %{HTTP_HOST} ^evearth.net [NC]RewriteRule ^(.*)$ [url="http://www.evearth.net/$1"]http://www.evearth.net/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} evearth.netRewriteCond %{REQUEST_URI} !evearth/RewriteRule ^(.*)$ evearth/$1 [L]#RewriteCond %{HTTP_HOST} ^gregscorvette.com [NC]RewriteRule ^(.*)$ [url="http://www.gregscorvette.com/$1"]http://www.gregscorvette.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} gregscorvette.comRewriteCond %{REQUEST_URI} !gregscorvette/RewriteRule ^(.*)$ gregscorvette/$1 [L]## RewriteCond %{HTTP_HOST} ^iribbit.net [NC]# RewriteRule ^(.*)$ [url="http://www.iribbit.net/$1"]http://www.iribbit.net/$1[/url] [L,R=301]# RewriteCond %{HTTP_HOST} iribbit.net# RewriteCond %{REQUEST_URI} !i/# RewriteRule ^(.*)$ i/$1 [L]#RewriteCond %{HTTP_HOST} ^kenmccafferty.com [NC]RewriteRule ^(.*)$ [url="http://www.kenmccafferty.com/$1"]http://www.kenmccafferty.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} kenmccafferty.comRewriteCond %{REQUEST_URI} !kenmccafferty/RewriteRule ^(.*)$ kenmccafferty/$1 [L]#RewriteCond %{HTTP_HOST} ^voteken.net [NC]RewriteRule ^(.*)$ [url="http://www.voteken.net/$1"]http://www.voteken.net/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} voteken.netRewriteCond %{REQUEST_URI} !voteken/RewriteRule ^(.*)$ voteken/$1 [L]#RewriteCond %{HTTP_HOST} ^lakeviewautomotive.com [NC]RewriteRule ^(.*)$ [url="http://www.lakeviewautomotive.com/$1"]http://www.lakeviewautomotive.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} lakeviewautomotive.comRewriteCond %{REQUEST_URI} !lakeviewautomotive/RewriteRule ^(.*)$ lakeviewautomotive/$1 [L]#RewriteCond %{HTTP_HOST} ^lilpeasboutique.com [NC]RewriteRule ^(.*)$ [url="http://www.lilpeasboutique.com/$1"]http://www.lilpeasboutique.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} lilpeasboutique.comRewriteCond %{REQUEST_URI} !lilpeasboutique/RewriteRule ^(.*)$ lilpeasboutique/$1 [L]#RewriteCond %{HTTP_HOST} ^lirdies.com [NC]RewriteRule ^(.*)$ [url="http://www.lirdies.com/$1"]http://www.lirdies.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} lirdies.comRewriteCond %{REQUEST_URI} !lirdies/RewriteRule ^(.*)$ lirdies/$1 [L]#RewriteCond %{HTTP_HOST} ^rsssource.net [NC]RewriteRule ^(.*)$ [url="http://www.rsssource.net/$1"]http://www.rsssource.net/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} rsssource.netRewriteCond %{REQUEST_URI} !rsssource/RewriteRule ^(.*)$ rsssource/$1 [L]#RewriteCond %{HTTP_HOST} ^soniastein.com [NC]RewriteRule ^(.*)$ [url="http://www.soniastein.com/$1"]http://www.soniastein.com/$1[/url] [L,R=301]RewriteCond %{HTTP_HOST} soniastein.comRewriteCond %{REQUEST_URI} !soniastein/RewriteRule ^(.*)$ soniastein/$1 [L]#

You can see this handles parent domains as well as subdomains. On a side note, since I am offering hosting for these sites, I've added an RSS file to each of them - essentially advertising all the other sites in my little network.Hope that helps.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...