.htaccess and rewrite rule 404 not found -


i'm new on .htaccess , rewrite rules. if question not relevant, please forgive me.

i have below htaccess code.

rewriterule ^([^/]+)/([^/]+)/?$ article-list.php?link=$1&page=$2 [l,qsa]

if visit url www.example.com/category/0 works. if strip page url , last slash www.exapmle.com/category see ugly 404 page.

what wrong htaccess directive?

thanks in advance.

edit: compeletely .htaccess

options +followsymlinks -multiviews rewriteengine on rewritebase /  ## if request valid directory rewritecond %{request_filename} -d [or] ## if request valid file rewritecond %{request_filename} -f [or] ## if request valid link rewritecond %{request_filename} -l ## don't rewriterule ^ - [l]  rewriterule ^haber/([^/]+)-([^/]+)/?$ article.php?link=$1&i=$2 [l,qsa] rewriterule ^([^/]+)/([^/]+)/?$ article-list.php?link=$1&page=$2 [l,qsa] 

this correct behaviour.
actually, in regular expression, + means at least one.

when use ([^/]+) means at least 1 character not slash.
rule ^([^/]+)/([^/]+)/?$ means at least 1 character not slash / at least 1 character not slash optional slash.

that's why not work first part url. if want handle example.com/category you'll need rule:

rewriterule ^([^/]+)/?$ article-list.php?link=$1 [l] rewriterule ^([^/]+)/([^/]+)/?$ article-list.php?link=$1&page=$2 [l] 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -