Sercan Kucukdemirci
Sercan Kucukdemirci

Reputation: 97

htaccess rewrite rule stops at first occurrence

I have a htaccess file to match all of the occurrences. but it stops at second one. when i load /galeri/kategori/galeri-kategory-albumname/ it loads sayfa.php which has no relation with gallery page itself. It works fine on my localhost but trying to figure out why its not working in server.

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?)$ index.php?p=$1 [L]
RewriteRule ^(.*?)\/sayfa(.*?)$ index.php?p=$1&sayfa=$2 [L]
RewriteRule ^(.*?)\/kategori\/(.*?)\/$ index.php?p=$1&kategori=$2 [L]
RewriteRule ^(.*?)\/kategori\/(.*?)\/(.*?)\/$ index.php?p=$1&kategori=$2&sayfa=$3 [L}

Upvotes: 2

Views: 251

Answers (1)

anubhava
anubhava

Reputation: 784878

Have it this way:

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^(.*)/kategori/(.*)/(.*)/?$ index.php?p=$1&kategori=$2&sayfa=$3 [L,QSA]

RewriteRule ^(.*)/kategori/(.*?)/?$ index.php?p=$1&kategori=$2 [L,QSA]

RewriteRule ^(.*)/sayfa(.*?)/?$ index.php?p=$1&sayfa=$2 [L,QSA]

RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]

Upvotes: 2

Related Questions