Habip Oğuz
Habip Oğuz

Reputation: 1193

.htaccess rewrite rule did not work

In my site there is a membershp system. Users' profile page likes profile.php?u=username I want to show url like http://sitename.com/username So I wrote in .htaccess

RewriteRule ^profile profile.php [L] 
RewriteRule ^([^/]*)$ profile.php?u=$1 [L]

When you go to http://sitename.com/profile, the page shows general information about system. And http://sitename.com/username shows username profile. But When I want to go http://sitename.com, http://sitename.com/profile psgr show, the index.page (main page) not shown. How can I do it?

Upvotes: 1

Views: 104

Answers (1)

anubhava
anubhava

Reputation: 785128

Keep your .htaccess like this:

DirectoryIndex index.php

RewriteEngine On
RewriteBase /

RewriteRule ^profile/?$ profile.php [L]

RewriteRule ^ads/?$ advertisement.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ profile.php?u=$1 [L,QSA]

Upvotes: 2

Related Questions