php - .htaccess rewrite works when two params, but cant read first one with slash after -
this question has answer here:
- htaccess mod rewrite optional slash 1 answer
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¶m1=$2 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/([^/]+)$ index.php?page=$1¶m1=$2¶m2=$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¶m1=$2 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?page=$1¶m1=$2¶m2=$3 [l]
Comments
Post a Comment