I currently have my URL like so:
mysite.com/test/?country=uk&number=1234&search=British+Telecom&limit=8
which I want to be like this:
mysite.com/test/uk/1234/British-Telecom/8
I am familiar with Apache mod_rewrite to some extent but never come across Nginx version. Anyone have an idea?
Something else I found is that the site is Wordpress and normal pages work fine with the url being rewritten, but my code is in a separate non-wp folder. How come WP's .htaccess seems to work when Apache is not running?
Another complication is that I have Varnish cache working - could this interfere?
you must capture get variables with ([^/]*)
regex and then use it with $1
, $2
...
use a htaccess like this :
RewriteEngine on
RewriteRule ^test/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ ./yourScript.php?country=$1&number=$2&search=$3&limit=$4 [L]
change
yourScript.php
with your script name .
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.