How to hide GET variables, but keep value
How would I go about doing something like this:
www.website.com/process.php?ip=32.313.131.31
to
开发者_开发百科www.website.com/32.313.131.31
Use a URL rewriting module. If you are using Apache, mod_rewrite is the tool for the job. In your case, a rule like this should suffice:
RewriteRule ^/(\d+\.\d+\.\d+\.\d+) /process.php?ip=$1
If you want a more general rule that doesn't just match IP addresses, it becomes trickier, because you don't want the rule to match the rewritten form, in case it is inadvertently specified in a link somewhere (e.g., you don't want www.website.com/process.php?ip=32.313.131.31
to be rewritten as www.website.com/process.php?ip=process.php?ip=32.313.131.31
).
I assume you're using Apache, so you could use mod_rewrite to achieve this. Create a .htaccess
file in your document root directory and create a rewrite rule to pass all requests that look like IP addresses to process.php. Something like this should do:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/\d+\.\d+\.\d+\.\d+$ /process.php?ip=$1 [NC]
精彩评论