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
https://forums.phpfreaks.com/topic/266567-mod-rewrite-help/
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
https://forums.phpfreaks.com/topic/266567-mod-rewrite-help/#findComment-1366105
Share on other sites

Archived

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

×
×
  • 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.