需要一些关于 apache mod-rewrite 问题的帮助
我已修改我的 .htaccess 文件以包含以下语句
RewriteCond $1 !^index.php$
RewriteRule ^/?([^/]+)$ index.php?c=home&m=details&seo=$1 [L,NS]
这允许我像这样使用产品 URL: http://domain .com/product_name
但是,当尝试访问与index.php同一级别的文件时,它总是调用上面的RewriteRule并出错。
我需要能够访问如下文件,但每个 URL 当前都尝试加载 index.php。 http://domain.com/about.htm
http://domain.com/terms.htm
http://domain.com/robots.txt
?
关于如何修改我的 htaccess 文件以使其正常工作有什么建议吗
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 me 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望文件胜过产品,您可以考虑另一个条件:
...这意味着只有当请求的 URI 未映射到文件时,才应将其视为产品。
拥有像这样的文件胜过产品并不可怕,除非您计划拥有名称为“something.html”和“dynamic.php”或“lenna.jpg”的产品。
If you want files to trump products you could toss in another condition:
...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".