I have a website example.com and I am passing two GET parameters in the url.
example.com/page.php?page=5§ion=10
Now I want it to show
example.com/5/10
I’ve already got it to work for the first part but cannot seem to figure out the second part (section part)
My current .htaccess file is
RewriteEngine on
RewriteCond %{THE_REQUEST} s/+page.php?page=(d+) [NC]
RewriteRule ^ /%1? [R=301,L,NE]
RewriteRule ^(d+)/?$ page.php?page=$1 [L,QSA,NC]
All I need to get is the second part working (§ion=10)
2
Answers
You can use this
Add this to your
.htaccess
:This grabs the variables using
{QUERY_STRING}
and rewrites your URL tohttp://example.com/5/10
. The use of the?
on the end of the rewrite is to stop the query from appending onto the end after the rewrite.Make sure you clear your cache before testing this.