Forum Moderators: phranque
Here is an example of my rewrite and URL format:
# Category Rewrite
RewriteRule ^(.*)\.html /shop/index.php?page=c&ccode=$1
# Product Rewrite
RewriteRule ^(.*)/(.*)\.html /shop/index.php?page=p&pcode=$2&ccode=$1
Category URL:
[domain.com...]
Product URL:
[domain.com...]
Everything works fine until I try to access the /links/ directory. It is still trying to load the /shop/index.php stuff. Any ideas? Thanks!
1) Most-specific rules go first
2) Use more-specific patterns -- avoid ".*" if possible
3) Stop the rewrite engine using [L] unless you need to process more rules after the one that matches
Like:
# Product Rewrite
RewriteRule ^([^/]+)/([^.]+)\.html$ /shop/index.php?page=p&pcode=$2&ccode=$1 [L]
# Category Rewrite
RewriteRule ^([^.]+)\.html$ /shop/index.php?page=c&ccode=$1 [L]
RewriteEngine On
RewriteCond %{REQUEST_URI}!-s
DirectoryIndex /shop/index.php
# Product Rewrite
RewriteRule ^([^./]+)/([^./]+)\.html$ /shop/index.php?page=p&pcode=$2&ccode=$1 [L]
# Category Rewrite
RewriteRule ^([^./]+)\.html$ /shop/index.php?page=c&ccode=$1 [L]
Any other ideas? Thanks!
Just exclude that page from being rewritten by any rule it otherwise might match:
# Product Rewrite
# This rule matches requests for /<directory>/<filename>.html
#
# exclude /links/ directory
RewriteCond %{REQUEST_URI} !^/links/index\.html$
# rewrite everything else
RewriteRule ^([^./]+)/([^./]+)\.html$ /shop/index.php?page=p&pcode=$2&ccode=$1 [L]
#
#
# Category Rewrite
# This rules rewrites all URLs of the form /<filename>.html
# except for those rewritten by the rule above
RewriteRule ^([^./]+)\.html$ /shop/index.php?page=c&ccode=$1 [L]