Jump to content

Mod rewrite help


Pain

Recommended Posts

Hi there.

 

I'm have a rewritten url for a social site members and it looks like this:

 

http://theWeb.net/user_nickname

 

However i would like it to look like:

 

http://theWeb.net/member/user_nickname

 

Can i somehow do this with mod rewriting?

 

I've got some code from the .htaccess, your help would be very much appreciated!

 

RewriteBase /

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteRule ^user_profile-([0-9]+)\.php$ user_profile.php?id=$1

RewriteRule ^user-profile/([a-zA-Z0-9_-]+)/([0-9]+)\.php$ user_profile.php?id=$2

RewriteRule ^([a-zA-Z0-9_-]+)$ user_profile.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user_profile.php?username=$1

 

 

 

 

Link to comment
Share on other sites

RewriteRule ^([a-zA-Z0-9_-]+)$ user_profile.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user_profile.php?username=$1

Those are the two you'll want to change, but first

RewriteRule ^([a-zA-Z0-9_-]+)/?$ user_profile.php?username=$1

they can be combined into just the one. So modify that to include the directory (take a stab at it) and replace it in.

Link to comment
Share on other sites

Thanks for the answer! This is what i've come up with:

 

RewriteRule ^member/([a-zA-Z0-9_-]+)/?$ user_profile.php?username=$1

 

Looks like it does work, however i think i must create an actual directory called 'member'?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.