开发者

Needs some help with an apache mod-rewrite issue

开发者 https://www.devze.com 2022-12-25 00:02 出处:网络
I\'ve modified my .htaccess file to have the following statement RewriteCond $1 !^index.php$ RewriteRule ^/?([^/]+)$ index.php?c=home&m=details&seo=$1 [L,NS]

I've modified my .htaccess file to have the following statement

RewriteCond $1 !^index.php$
RewriteRule ^/?([^/]+)$ index.php?c=home&m=details&seo=$1 [L,NS]

This allows m开发者_如何学Ce to use product URL's like this: http://domain.com/product_name

However, when trying to access a file at the same level as index.php, it always calls the RewriteRule above and errors out.

I need to be able to access files like below, but each URL currently attempts to load index.php. http://domain.com/about.htm

http://domain.com/terms.htm

http://domain.com/robots.txt

etc

Any suggestions on how I can modify my htaccess file to get this to work correctly?


If you want files to trump products you could toss in another condition:

RewriteCond $1 !^index.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?([^/]+)$ index.php?c=home&m=details&seo=$1 [L,NS]

...meaning that only if the requested URI doesn't map to a file should it be treated as a product.

Having files trump products like this isn't terrible unless you plan on having products with names like "something.html" and "dynamic.php" or "lenna.jpg".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号