Hi everyone, I have a website that gives me the following url when viewing a users profile.


I am trying to create a htaccess rule that will generate a friendly url like

The existing htaccess file is

RewriteEngine on
RewriteCond %{request_filename} -f
RewriteRule ^(.*) $1 [L]
RewriteRule ^([a-z]+)(/([^/]{0,32})(/.+)?)?$  index.php?a=$1&u=$3    [L]

Thanks in advance...

Thanks @mmcdonald - I will give that ago...

Hi, That didnt do the trick...

Do you have any other rules that could interfere?

To make:
**The original URL:**

**The rewritten URL:**

RewriteEngine On
RewriteRule ^a/([^/]*)/u/([^/]*)\.html$ /index.php?a=$1&u=$2 [L]
To make:
**The original URL:**

**The rewritten URL:**

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.php$ /index.php?a=$1&u=$2 [L]

The first rule sample that mmcdonald provide is accurate. I quicly tested it myself even though it looked accurate.

My experience with rewriting questions is that some people seem to be confused about the process... For example... if you type this in the URL:


That will not be redirected to http://website.com/profile/username

URL rewriting works in that it takes the friendly URL so the visitor doesnt have to see or know the actual page or parameters.

So, your user will type this URL: http://website.com/profile/username

You take care of the backend process of getting the correct page and parameters processed.

Thanks for testing and feeding back your results JorgeM. Explaining URL rewriting was a smart move.


Thanks gents, very much appreciated, I will have a look through the website too see if I can find any other rules.

I am helping a friend out who had the website designed by a freelancer, who has suddenly gone missing after being paid.

That's nothing new Everton, I always use something like Escrow when dealing with Freelancers - but I'm sorry to hear it.

The above rewrite will work, perhaps it's being implemented incorrectly? It's been tested by JorgeM and he's a seasoned programmer.

Either way, good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.