简体   繁体   中英

About url rewrite with query string

Please help, how to make this url (in my request i use get function)

iplookup.php?lookup_ip=66.249.66.1

to looks like this?

/ip/66.249.66.1

with

RewriteCond %{QUERY_STRING} lookup_ip=
RewriteRule ^ip/(.*)$ iplookup.php?lookup_ip=$1 [QSA]

But unsuccessful :(

Get rid of the condition. The RewriteCond %{QUERY_STRING} lookup_ip= condition is only true if lookup_ip= is in the query string, and obviously the URI /ip/66.249.66.1 doesn't have one. Your rule should just look like this:

RewriteRule ^ip/(.*)$ /iplookup.php?lookup_ip=$1 [L,QSA]

Then when you request http://yourdomain.com/ip/12.34.56.78 , the browser's URL address bar remains unchanged while you get served the content at /iplookup.php?lookup_ip=12.34.56.78 . You just need to make sure all of your links look like http://yourdomain.com/ip/12.34.56.78 .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM