0

What i wanted to do is first hide all .php extensions in my URL secondly i wanted all users to have there pages with there usernames like www.domain.com/username however i can easily do the first with this code in my .htaccess.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)$ $1.php

Now how can i do the second part as if somebody goes to this domain www.domain.com/username server will route to www.domain.com/username.php but it should go to URL like www.domain.com/profile.php?id=username.

How can i achieve this?

Nikola K.
  • 7,093
  • 13
  • 31
  • 39
Abdul Basit
  • 493
  • 11
  • 34

1 Answers1

0

Something like this, however it will redirect everything after the / to profile.php, so you have to make rules for all other urls before this, if needed.

RewriteRule (.*) profile.php?id=$1
Kao
  • 2,242
  • 3
  • 22
  • 31
  • you mean to say php rules ? or rules in htaccess... but what if i write this www.domain.com/artist-signup it will go to profile.php ? it should go to www.domain.com/artist-signup.php can u please guide or make rules if its in .htacess – Abdul Basit Jul 20 '12 at 10:31
  • What you can do is RewriteRule (.*) $1.php This is a rule for .htaccess. – Kao Jul 20 '12 at 10:35
  • actually your not telling it the things i need to know RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f i think i should change them for !-f before using the above Rewrite Rule u mentioned RewriteRule (.*) profile.php?id=$1 – Abdul Basit Jul 20 '12 at 13:19