| 
	
 | 
 Posted by Justin Koivisto on 02/11/06 09:04 
frizzle wrote: 
> Justin Koivisto wrote: 
>  
>>frizzle wrote: 
>> 
>>>Hi group, 
>>> 
>>>I know this isn't the right group, but i didn't know what group else it 
>>>should be. 
>>>I have a php/mySQL system, wich uses mod rewrite to enhance urls. 
>>> 
>>>I have the following RewriteRule: 
>>> 
>>>     RewriteRule 
>>>^news(/[0-9]{4}(/[0-9]{2}(/[A-z0-9_-]+)?)?)?)?(/(index\.html)?)?$ 
>>>index.php 
>>> 
>>>Allows urls as: 
>>> 
>>>     domain.com / news / 2006 / 02 / some_news-itemName / index.html 
>>> 
>>>structure: 
>>> 
>>>     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 
>>>url, like 
>>> 
>>>     index.php?year=2006&month=02&topic=some_news-itemName 
>>> 
>>>$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'. 
>> 
>>Try something like this (notice where the groups are and the ? operator): 
>> 
>>RewriteRule ^news(/[0-9]{4})?(/([0-9]{2}))?(/([^/]+))?(/(index\.html))?$ 
>>index.php?year=$1&month=$3&topic=$5 
>  
>  
> Doesn't this allow me to define a month in the url, without defining a 
> year? 
 
Yes, that would, maybe something more like this then (untested): 
 
RewriteRule ^news(/([0-9]{4})/([0-9]{2})/([^/]+))?(/(index\.html)?)?$ 
index.php?year=$2&month=$3&topic=$4
 
  
Navigation:
[Reply to this message] 
 |