简体   繁体   中英

(.Htaccess) Doesn't working at all. Every time fail to prevent direct access from address bar why ?

I'm building a wedding photo hosting site. Where I want to Show the Images but not direct access from address by using "view source" and find direct image link. I search here a lot. I find solution.

RewriteEngine on 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost:81 [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost:81.*$ [NC] 
RewriteRule \.(gif|jpg)$ - [F]

Something like this :81 is my port. I've tried to test in localhost but every time its fail. Someone write there that it's may be opening from cache but I cleared cache and then try again Still same problem. I'm using CodeIgniter/Php and I put that .htaccess file in the Image folder and once in root. What is the problem. My root folder is http://localhost:81/Project

You can use this..
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
ErrorDocument 404 index.php

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