Mehmet
Mehmet

Reputation: 3347

URL rewrite rules with Apache

I have a .htaccess file like this:

RewriteEngine On

RewriteRule ^([\w-]+)/([\w-]+)/?$ profile.php?username=$1&w=$2 [QSA,L]
RewriteRule ^([\w-]+)/?$ profile.php?username=$1 [QSA,L]
RewriteRule ^p/timeline timeline.php [NC,L]
RewriteRule ^p/notifications notifications.php [NC,L]

I can use my url like this

www.mysite.com/username
or
www.mysite.com/username/photos

But some rules does not work. For example:

www.mysite.com/p/timeline

There is a problem with url which include mysite.com/p/..

Anyone can help me?

Upvotes: 1

Views: 34

Answers (1)

hjpotter92
hjpotter92

Reputation: 80639

You should first parse the rules for p/timeline and p/notification. The ordering of your rules is also important.

RewriteEngine On

RewriteRule ^p/(notifications|timeline) $1.php [NC,L]
RewriteRule ^([\w-]+)/([\w-]+)/?$ profile.php?username=$1&w=$2 [QSA,L]
RewriteRule ^([\w-]+)/?$ profile.php?username=$1 [QSA,L]

Upvotes: 2

Related Questions