简体   繁体   中英

htaccess exclude a page from rule

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?pirate-punk.com(/)?.*$     [NC]
RewriteRule ([^/]+\.[a-z0-9]+)$ http://www.pirate-punk.com/dl.php?f=$1 [R,NC,L]

Options +Indexes 

This htaccess will redirect all incoming traffic to another page if they come from a different domain.

I would like to exclude all index.php pages from this rule so my visitors can still visit an index.php page even if they come from outside of the domain

How can i do that ?

You can just add a condition which excludes anything that ends with a / or /index.php :

RewriteEngine On

RewriteCond %{REQUEST_URI} !/(index\.php)?$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?pirate-punk.com(/)?.*$     [NC]
RewriteRule ([^/]+\.[a-z0-9]+)$ http://www.pirate-punk.com/dl.php?f=$1 [R,NC,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM