Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Htaccess question w/ mod rewrite
February 9, 2006, 12:38 am
rate this thread
I know this isn't the right group, but i didn't know what group else it
I have a php/mySQL system, wich uses mod rewrite to enhance urls.
I have the following RewriteRule:
Allows urls as:
domain.com / news / 2006 / 02 / some_news-itemName / index.html
domain / news / year / month / news item's name
A trailing slash, and optionally 'index.html' are alwas allowed this
way, an item name can only be given if a month is defined, which can
only be defined if a year is defined.
Now how can i divide the different information parts into $_GET in the
$1 gives me: /2006/02/some_news-itemName
$2 gives me: /02/some_news-itemName
$3 gives me: /some_news-itemName
$4 gives me: /index.html
$5 gives me: index.html
So i'd like the $_GET's to be more 'precise'.
Hope it's clear!
Re: Htaccess question w/ mod rewrite
A very easy way is to look at $_SERVER["REQUEST_URI"]. If you explode("/",
$_SERVER["REQUEST_URI"]), you get an array of the individual directories in
your request, each one corresponding to a variable. If you're worried about
portability, there is a free library for IIS that does the same as
mod_rewrite, and it even sets a similar header.
Hope that helps!