0

In reference to: Multiple rule Apache rewrite

While this works great for the multiple levels of item drill down I still have need for an admin.php page to run outside of the rule. Currently under this set of rules standard page/scripts wont run.

Thoughts/Ideas?

RewriteRule ^mr/index.php$ - [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ /mr/index.php?product_group=$1&product_family=$2&product_category=$3&product_sub_category=$4&product=$5 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$         /mr/index.php?product_group=$1&product_family=$2&product_category=$3&product_sub_category=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$                 /mr/index.php?product_group=$1&product_family=$2&product_category=$3 [L]
RewriteRule ^([^/]*)/([^/]*)/?$                         /mr/index.php?product_group=$1&product_family=$2 [L]
RewriteRule ^([^/]*)/?$                                 /mr/index.php?product_group=$1 [L]

UPDATE:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ - [L]

RewriteRule ^index.php$ - [L]

RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?n_section=$1&n_product_group=$2&n_product_family=$3&n_product_category=$4&n_product_subcategory=$5 [L]

RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$         index.php?n_section=$1&n_product_group=$2&n_product_family=$3&n_product_category=$4 [L]

RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$                 index.php?n_section=$1&n_product_group=$2&n_product_family=$3 [L]

RewriteRule ^([^/]*)/([^/]*)/?$                         index.php?n_section=$1&n_product_group=$2 [L]

RewriteRule ^([^/]*)/?$                                 index.php?n_section=$1 [L]
xxx
  • 33
  • 5
  • Do you want to have all files/scripts that actually exist exempted from this set of rules, then? – Shane Madden Nov 22 '13 at 17:02
  • Shane, I'm not sure. I'm just learning mod_rewrite and am working on a revision of my CMS system. With these rules it appears I can't have standard pages, like admin.php. I guess it would be good to learn how to add that single page in as an exception and how to add others. – xxx Nov 23 '13 at 01:44
  • Well, so I guess the question is -- would you rather just have a blanket rule that exempts all content from these rules as long as the file exists? Given that you probably have CSS, Javascript, and image files that are all static content, this is probably the typical approach. – Shane Madden Nov 23 '13 at 08:16
  • Then yes. There is always some static content and a blanket rule might be best. – xxx Nov 23 '13 at 12:38

1 Answers1

2

Put these lines at the top, above the existing RewriteRule lines. What it'll do is check to see if the requested file exists, and if so it'll skip the rest of the rewriting process, ignoring all the subsequent rules.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ - [L]
Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • Shane, Just got a change to try this out. It doesn't seem to work. If I add the above condition admin.php page loads fine but then the rest of the rule(s) fail if those conditions are called. xyz.com/level1/level2/level3 (etc) wont work but xyz.com/admin.php will. – xxx Nov 26 '13 at 14:21
  • @nino Can you edit your question with what the full config looks like now? – Shane Madden Nov 26 '13 at 17:52