根据此线索:Proper的正则表达式的.htaccess重定向和热链接prevention
我问一个更集中的问题(盗链解决)。
I am asking a more focused question (hotlinking is solved).
我在做一个镜像主机的项目,并正在编码图像名称。我需要提供短网址的用户访问自己的形象。下面进行内部重定向:
I am doing an image host project and am encoding image names. I need to provide a short url for the users to access their images. The following should be internally redirected:
domain.com/hsh1h.jpg(或其它图像扩展) domain.com/hsh1h
domain.com/hsh1h.jpg (or other images extensions) domain.com/hsh1h
这些是内部重定向到: domain.com/image.php?query=hsh1h.jpg domain.com/image.php?query=hsh1h
These would be internally redirects to: domain.com/image.php?query=hsh1h.jpg domain.com/image.php?query=hsh1h
的问题是,下面的网址的不应被重定向:
The issue is that the following url's should not be redirected:
domain.com/admin domain.com/admin/index.php
domain.com/admin domain.com/admin/index.php
我创建较早的一个令人困惑的话题道歉,并感谢大家这么多的帮助!
I apologize for creating a confusing topic earlier and thank you all so much for your help!
尝试:
# these rules ensure you aren't clobbering legit requests (like to image.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# just in case, exclude the admin directory
RewriteCond %{REQUEST_URI} !^/admin
# rewrite
RewriteRule ^(.*)$ image.php?query=$1 [L]