Umar Farouq Khattab
Umar Farouq Khattab

Reputation: 51

Framework style URLs

I am working on a project and I want to make the urls similar with the ones in use now.

For example, on stackoverflow, the urls do not end in .php (or any server side extension for that matter).

I want to be able to achieve that, I just do not know hot to go about it.

Upvotes: 1

Views: 70

Answers (2)

virtualeyes
virtualeyes

Reputation: 11237

Depends on what you want to do really. Stacko may be routing all requests via a base controller. For example, to do that in Apache you would:

# if no file extension exists, route request to controller
RewriteCond   %{REQUEST_URI} !\.+
RewriteRule   ^/(.*) /Controller\.php/$1 [l]

If your controller (and code base) live elsewhere on filesystem from client code, you can do:

RewriteCond   %{REQUEST_URI} !\.+
RewriteRule   ^/(.*) /Controller\.php/$1 [PT] # pass through to boostrapper
Alias /Controller.php /path/to/code/base/Bootstrap.php

Upvotes: 1

kieran
kieran

Reputation: 2312

mod_rewrite - http://httpd.apache.org/docs/current/mod/mod_rewrite.html

This is a really useful rewrite wizard to get you started

http://www.generateit.net/mod-rewrite/

Also just have a search on stackoverflow for mod_rewrite and .htaccess - you'll find tones of stuff.

Upvotes: 0

Related Questions