Apache Web Server mod_rewrite file path restriction question

Asked 2 years ago, Updated 2 years ago, 101 views

Ubuntu 16.04 LTS, Apache2 is in use as virtualBox. I changed the file from "Server Domain/File Path" to "Server Domain/rewrite Rule" using the rewrite module. The problem is that I want to access the file only for "Server Domain/rewriteRule" and "Server Domain/File Path" to display Not Found, but both have access to the file.

Is there a way to solve it with Apache settings?

php webserver apache mod-rewrite

2022-09-21 19:59

1 Answers

They say that they use the following method to prevent using only the images on their site by referring directly from the outside.

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

I'm sharing it because I think we can use php instead of gif or jpg by applying this. Source


2022-09-21 19:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.