Question

Every signed up member has an userprofile. The URL looks like: http://domain.com/content/profile/profile.php?username=USERNAMEOFTHEUSER

How do I rewrite it so it shows the URL as: http://domain.com/USERNAMEOFTHEUSER ?

I've tried:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^([^/]*)\.html$ content/profile/$1 [L,QSA]

But it aint working and I have no htaccess knowledge.

EDIT #1

Also, my map structure looks like this:

content/example1/example_file1.php
content/example2/example_file2.php
content/example3/example_file3.php

How do I hide the content/examples/ maps? So that: domain.com/content/example2/example_file2.php

turns into domain.com/example_file2 ?

Thanks!

Was it helpful?

Solution

This should work:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /content/profile/profile\.php\?username=(.*)\ HTTP
RewriteRule ^ /%2? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /content/profile/profile.php?username=$1 [L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top