I've searched all over the web but have not been able to find answers, so i hope you can help me.
I try to rewrite both the page and the category in my Htaccess as follows: example.com/page.php?cat=berlin&page=2 to example.com/berlin/2. Category can be different like Stockholm, Oslo, Copenhagen ...
Is there anybody inside that can show me how to do it? Or refer to a place where they show it correctly. I have try to use %1 but it did not work.
RewriteRule ^(.*)$ /book.php?url=$1 [L]
You would need to use back-references and multiple capture groups to accomplish this. So something like:
RewriteRule ^/page.php\?cat=([a-z]+)&page=([0-9]+)$ /$1/$2 [L]
This is making several assumptions, including that cat
is always alpha characters and page
is always numeric. Also see the apache documentation here , specifically the section on Regex Back-Reference Availability.
Also, %1
would match a capture group in a preceding RewriteCond
not the current RewriteRule
which uses the $1
notation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.