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] 
4
  • Do you want to have all files/scripts that actually exist exempted from this set of rules, then? Commented Nov 22, 2013 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. Commented Nov 23, 2013 at 1: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. Commented Nov 23, 2013 at 8:16
  • Then yes. There is always some static content and a blanket rule might be best. Commented Nov 23, 2013 at 12:38

1 Answer 1

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] 
2
  • 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. Commented Nov 26, 2013 at 14:21
  • @nino Can you edit your question with what the full config looks like now? Commented Nov 26, 2013 at 17:52

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.