Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's an example URL to a user profile on my site:

I want it to be:

This is what I have for rewrite rules:

  Options -MultiViews
  RewriteEngine On
  RewriteBase /php-login/
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-l

  RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

That gets rid of the .php at the end.

I've also tried adding

RewriteRule ^(.+)$ index.php?url=/overview/showuserprofile/$1 [QSA,L]

But the URL would change and not any of the pages.

Any ideas?

share|improve this question

You will need to figure out how to differentiate user pages from other pages. Your rewrite expression ^(.+)$ matches all the pages on the site except for the home page. You will need to limit this so that it doesn't match other pages including index.php.

One way of doing so would be to only allow user pages to use lower case letter with no punctuation. Then it wouldn't match index.php due to the period. The rewrite rule for that would be:

RewriteRule ^([a-z]+)$ index.php?url=/overview/showuserprofile/$1 [QSA,L]

Another way to do it would be to check that there isn't a real file with that name as a rewrite condition using the instructions here: http://www.harecoded.com/apache-rewritecond-f-check-file-exists-solution-2246468

share|improve this answer
So by doing that and merging my other solution together they should work? So something like this? RewriteRule ^([a-z]+)$ index.php?url=/overview/showuserprofile/$1 [QSA,L] – John Mar 15 '14 at 0:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.