building a site which has content for each section.

urls range from;
/work/print/folders etc.

however, at any point a user can click on an article so;

using .htaccess i need to detect when there is 'article' in the url and set some different variables.

RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/$ 
sets  index.php?level1=$1&level2=$2&level3=$3&level4=$4

but if 'article/([0-9-]+)' is in the url, say /work/print/article/1066 return index.php?level1=$1&level2=$2&articleID=1066

basically the amount of levels will always be different but i'd like to return those as needed. another example would /work/print/folder/archive/article/1066 return


any help appreciated! Dan

Accepted Answer

in the end i just did it manually! (though would prefer a more expansive solutions)

# MENU ###

RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/$  index.php?level1=$1&level2=$2&level3=$3 [L]

RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/$  index.php?level1=$1&level2=$2 [L]

RewriteRule ^([a-zA-Z0-9\-]+)/$  index.php?level1=$1 [L]

###  WITH ARTICLE  ###

RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/article/([0-9\-]+)/([a-zA-Z0-9\-]+)$$  index.php?level1=$1&level2=$2&level3=$3&articleID=$4 [L]

RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/article/([0-9\-]+)/([a-zA-Z0-9\-]+)$$  index.php?level1=$1&level2=$2&articleID=$3 [L]

RewriteRule ^([a-zA-Z0-9\-]+)/article/([0-9\-]+)/([a-zA-Z0-9\-]+)$  index.php?level1=$1&articleID=$2 [L]

RewriteRule ^$  index.php?level1=home [L]
Written by daniel Crabbe
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the community.
It is licensed under cc-wiki