문제

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!

도움이 되었습니까?

해결책

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top