|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
RewriteRule: "using more than one path"
Hard to explain in the subject what I need.
I have these rules inside my httpd.conf: RewriteRule ^/articles/([0-9]+)/(en|it).htm$ /src/articles.php?lang=$2&id=$1 [T=application/x-httpd-php,L] RewriteRule ^/articles/(en|it).htm$ /src/articles.php?lang=$2 [T=application/x-httpd-php,L] The first is used to convert: /articles/11/it.htm -->> /src/articles.php?lang=it&id=11 the second is used to convert: /articles/it.htm -->> /src/articles.php?lang=it I use articles.php to view the article if $id is not empty, to display the list of articles if $id is empty. I'm asking if there is a way with regular expression to put these two rules inside one. I tried something like this: ^/articles/(([0-9]+)/(en|it).htm)|((en|it).htm)$ but with an orrible output. Is it possible or is it better to have two rules as I wrote? |
|
#2
|
|||
|
|||
|
Just don't use ([0-9]+), use ([0-9]*) instead, so that id can be empty.
You also should add a catch-all RewriteRule to display error message when it matches something under ^/articles(.*) but not your preceding Rule so that Apache knows what to do instead of throwing you with weird errors. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > RewriteRule: "using more than one path" |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|