sameold
sameold

Reputation: 19252

using / forward slash as a parameter

I have a single page index.php. I would like to accept parameters in the form /value. Right now, if I add anything after a /, it assumes I'm trying to access a separate file and errors out. Is there a way I could accept params by adding /value

Upvotes: 1

Views: 1124

Answers (2)

Ander2
Ander2

Reputation: 5658

You have to use apache's rewrite module. Check that rewrite_module is active. Then you could place a simple .htaccess file in you directory with the following rules to do the job:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !-d 
RewriteRule (.*) index.php?value=$1 [L,NS]

This rules with activate rewrite engine and place everythin after / into value variable.

Have a look to the rewrite documentation and then adjust the rules to your own.

Upvotes: 1

Eernie
Eernie

Reputation: 469

Maby you can have a look at Silex. This is a light weight framework and can do all your url desires.

Upvotes: 1

Related Questions