从一般 UrlRewrite 规则中排除脚本
我对网站有以下重写规则:
RewriteEngine On
# Stop reading config files
RewriteCond %{REQUEST_FILENAME} .*/web.config$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} .*/\.htaccess$ [NC]
RewriteRule ^(.+)$ - [F]
# Rewrite to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^(/bilder_losning/|/bilder/|/gfx/|/js/|/css/|/doc/).*
RewriteRule ^(.+)$ index.cfm?smartLinkKey=%{REQUEST_URI} [L]
现在我必须从上述规则中排除包含其最终查询字符串的脚本,以便我可以以正常方式访问和执行它,目前整个url 被忽略并转发到索引页。
我需要访问根目录中的脚本 shoplink.cfm,该脚本采用变量 tduid 和 url (shoplink.cfm?tduid=1&url=)
我尝试使用以下方法解决它:
# maybe?:
RewriteRule !(^/shoplink.cfm [QSA]
但老实说,我对 urlrewriting 没有太多了解,也不知道我应该写什么。我只知道上面会产生一个很好的 500 错误。
我在 stackoverflow 和其他网站上查找了很多关于同一主题的内容,但我看到的只是人们试图排除目录,而不是文件。在最坏的情况下,我可以将脚本添加到单独的目录中,并从重写规则中排除该目录,但不是因为脚本实际上应该保留在根目录中。
刚刚也尝试过:
RewriteRule ^/shoplink.cfm$ $0 [L]
但这也没有做任何事情。
谁能帮我解决这个问题?
提前致谢。
史蒂文·埃塞尔 ColdFusion 程序员
I have following rewrite rules for a website:
RewriteEngine On
# Stop reading config files
RewriteCond %{REQUEST_FILENAME} .*/web.config$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} .*/\.htaccess$ [NC]
RewriteRule ^(.+)$ - [F]
# Rewrite to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^(/bilder_losning/|/bilder/|/gfx/|/js/|/css/|/doc/).*
RewriteRule ^(.+)$ index.cfm?smartLinkKey=%{REQUEST_URI} [L]
Now I have to exclude a script including its eventually querystrings from the above rules, so that I can access and execute it on the normal way, at the moment the whole url is being ignored and forwarded to the index page.
I need to have access to the script shoplink.cfm in the root which takes variables tduid and url (shoplink.cfm?tduid=1&url=)
I have tried to resolve it using this:
# maybe?:
RewriteRule !(^/shoplink.cfm [QSA]
but to be honest, I have not much of a clue of urlrewriting and have no idea what I am supposed to write. I just know that above will generate a nice 500 error.
I have been looking around a lot on stackoverflow and other websites on the same subject, but all I see is people trying to exclude directories, not files. In the worst case I could add the script to a seperate directory and exclude the directory from the rewriterules, but rather not since the script should really remain in the root.
Just also tried:
RewriteRule ^/shoplink.cfm$ $0 [L]
but that didn't do anything either.
Anyone who can help me out on this subject?
Thanks in advance.
Steven Esser
ColdFusion programmer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请尝试将以下行放在配置的顶部(在 RewriteEngine 打开之后):
Please try to put the following line at the top of your config (after RewriteEngine on):