php - .htaccess rewrite works when two params, but cant read first one with slash after -


this question has answer here:

i know type of problem asked lot havent been able find resolution this.

my .htaccess code rewrites first param page, 3 after param1, param2, , param3. works fine, example when url "localhost/portal/dashboard" . when url "localhost/portal/dashboard/" (the slash), doesnt work , gives 404 error.

here .htaccess file:

rewriteengine on    rewritecond %{request_filename} !-f  rewritecond %{request_filename} !-d  rewriterule ^([^/]+)$ index.php?page=$1 [l]    rewritecond %{request_filename} !-f  rewritecond %{request_filename} !-d  rewriterule ^([^/]+)/([^/]+)$ index.php?page=$1&param1=$2 [l]    rewritecond %{request_filename} !-f  rewritecond %{request_filename} !-d  rewriterule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1&param1=$2&param2=$3 [l]

thanks in advance.

untested, adding optional slash end of rewrite matchers might work, so:

rewriteengine on  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/?$ index.php?page=$1 [l]  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/?$ index.php?page=$1&param1=$2 [l]  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?page=$1&param1=$2&param2=$3 [l] 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -