Sercan Kucukdemirci Sercan Kucukdemirci - 3 months ago 24
Apache Configuration Question

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}

Answer

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]
Comments