1

Sorry if the title of the question is not clear, please read below for details;

I have this .htaccess:

Options -Multiviews

RewriteEngine On    
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?user=$1

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/home/.*$ index.php [QSA]

One of its functions is to redirect the url from this example:

www.example.com/user.php?user=david

to be:

www.example.com/david

Now, I have a file friends.php which function is to show friends of a particular user.
So the link that I wanted is like this:

www.example.com/david/friends

How can I achieve this?

1
  • What should www.example.com/david/friends be rewritten to? Commented Dec 9, 2014 at 10:46

1 Answer 1

2

You have to basically do the same as you did for user. In fact, the rule does not even conflict, because the user rule cannot contain a / character.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/friends$ friends.php?user=$1 [L]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.