|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
mod_rewrite - Mod Rewrite Help Please!!!!!!
Hi,
I have started using Mod Rewrite and have a problem with displaying sub-directories re-writes. I'm trying to rewrite the following structure /menu/submenu/content/ I'm using RewriteRule ^/([^/]+)/?([^/]*)/?([^/]*)/?$ /content.aspx?pname=$1&pname2=$2&content=$3 [L] This does not work and it seems to conflict with an existing rule as follows: RewriteRule ^adverts/([^/]+)/?([^/]*)/?([^/]*)/?([^/]*)/?$ /detail.aspx?mak_id=$2&mod_id=$3&adv=$4 [L] This is the code used in the .htaccess file: ###################################### RewriteEngine On RewriteBase /web/content/ RewriteBase / ############ CMS ############ RewriteRule ^/([^/]*)/?$ /menu.aspx?pname=$1 [L] RewriteRule ^/([^/]+)/?([^/]*)/?$ /submenu.aspx?pname=$1&pname2=$2 [L] RewriteRule ^/([^/]+)/?([^/]*)/?([^/]*)/?$ /content.aspx?pname=$1&pname2=$2&content=$3 [L] ################################# ############ Adverts ############ RewriteRule ^taxis-for-sale/pg/([^/]+)/?$ /adverts.aspx?pg=$1 [L] RewriteRule ^taxis-for-sale/([^/]+)/?([^/]*)/?([^/]*)/?([^/]*)/?$ /detail.aspx?mak_id=$2&mod_id=$3&adv=$4 [L] RewriteRule ^taxis-for-sale/ /adverts.aspx [L] ################################# Can you please advise how I can implement the structure susccessfully without having to use the structure with the rule: RewriteRule ^content/([^/]+)/?([^/]*)/?([^/]*)/?$ /content.aspx?pname=$1&pname2=$2&content=$3 [L] This rule works but I don't want to use the content directory in front. The rule I would like to use is: RewriteRule ^/([^/]*)/?$ /menu.aspx?pname=$1 [L] RewriteRule ^/([^/]+)/?([^/]*)/?$ /submenu.aspx?pname=$1&pname2=$2 [L] RewriteRule ^/([^/]+)/?([^/]*)/?([^/]*)/?$ /content.aspx?pname=$1&pname2=$2&content=$3 [L] |
|
#2
|
|||
|
|||
|
Just move the adverts rules ahead of the others.
They're set for [L], so anything matching them will be the final rule. The content stuff doesn't match them, so requests will skip past the adverts rules to the next that match. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > mod_rewrite - Mod Rewrite Help Please!!!!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|