mothorool
mothorool

Reputation:

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/example 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

Upvotes: 0

Views: 362

Answers (3)

Erik
Erik

Reputation: 20712

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.

Upvotes: 0

Harmen
Harmen

Reputation: 22438

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

Upvotes: 0

Pentium10
Pentium10

Reputation: 207838

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

Upvotes: 2

Related Questions