how to send data in url in a different way then by using get method
I want to my adress look like this: www.example.com/112112/ex开发者_如何学编程ample
Where 112112
is a data, that I want to work with in a php script. How to do this? For some reasons, I dont want to the adress look like www.example.com?id=112112
You can use url rewrite to achieve the binding from www.example.com/112112/example to www.example.com?id=112112
For Apache webserver, you will find here a guide: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
This is about mod_rewrite
and .htaccess
-files, add a .htaccess-file to your webserver root and add this piece of code:
RewriteEngine On
RewriteRule ^(.*)/ index.php?id=$1
The easiest way to do this is if you're on a system using the Apache web server, along with mod_rewrite. To get the desired effect, you'd put a .htaccess in your directory with something like this:
RewriteEngine on
# Dont rewrite files or directories which actually exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite for example.com/100/example to example.com/page.php?id=100
RewriteRule ^([^/]+) page.php?id=$1
You can have lots of rules to cover different possibilities.
精彩评论