i want all of file in folder /client/ just available to access by subdomain.site.com
to another say i have Some swf(flash) file in folder /client/ For example /client/1.swf that if user enter this address in browser: site.com/client/1.swf
he can's access to this file Directly
but i want user just can accessible to site.com/client/1.swf address through subdomain.site.com
anybody can help me for set htaccess file !?
Try adding this to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^subdomain\.site\.com$ [NC]
RewriteRule ^client/ - [L,F]
If you would rather return a 404 instead of a 403 (forbidden) then change the stuff in the square brackets to: [L,R=404]
Another way is to Create an .htaccess file in client. Like /client/.htaccess Then put this code.
Apache 2.2
order deny,allow
deny from all
allow from 127.0.0.1
Apache 2.4
Require all denied
Require ip 127.0.0.1
Related
how i can:
ALLOW access to file from website
AND
DENY access to file from all which external to website
Using HTACCESS ?
For example website is stored in a webspace associated to domain: xxx.xx.
Inside a webpage i have a link as:
LINK
And:
Clicking on LINK then start video correctly
BUT
Typing from url (for example): http://www.xxx.xx/video/example.mp4 need return error 403 (denied access) blocking so playing and/or download of file: example.mp4
Thanks for help.
Since it is not easy to write a rule in comments, I am providing a rule which blocks access to a mp4 file based on HTTP_REFERER header value:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?xxx\.xx/ [NC]
RewriteRule ^video/example\.mp4$ - [F,NC]
However keep in mind that clients can spoof HTTP_REFERER header.
I have 3 php apps on one server. I cant modify any apache files. Haw can I set .htaccess to remove web/ folder from url?
192.168.45.54/app1/
192.168.45.54/app2/
192.168.45.54/app3/web - I want to change it to 192.168.45.54/app3/
On adress 192.168.45.54/app3/web/ everythink is working fine. But haw can I remove web/ from url?
I created .htaccess files:
RewriteEngine On
RewriteBase /app3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [QSA,L]
But when I go to 192.168.45.54/app3/ in symfony log files I have fallowing error:
No route found for "GET /app3/"
I use Symfony in 3.4 version. I think that problem is in .htaccess located in /web directory... Haw to configure .htaccess corectly?
I can't create virtual host becouse I haven't access to the server...
You need to make the web/ directory the document root of your website. If you have direct access to the webserver’s virtual host configuration, change the document root to the following line and restart Apache:
DocumentRoot /path/to/symfony/web/
If you can’t modify the virtual host file directly, your hosting provider will usually give you the possibility to modify the document root through some kind of online tool.
I have got a contact form on my website with file attachment as well, that has been restricted only to pictures. Although if I type in example.com/uploads/ all the files are accessible by anyone. Is htaccess the best way to hide it? Also how could I do that in a safe manner, without messing up the contact form?
I have tried this, but it blocks the whole website
deny from all
<Files ~ “^w+.(gif|jpe?g|png)$”>
order deny,allow
allow from all
</Files>
if I type in example.com/uploads/ all the files are accessible
You mean you get a directory listing? This can be disabled in .htaccess:
Options -Indexes
To actively block all HTTP requests for files in the /uploads directory (since you state in comments that these are only ever accessed over FTP) then all you need is (in your root .htaccess file):
RewriteEngine On
RewriteRule ^uploads - [F]
This will respond with a 403 Forbidden for all requests that start /uploads.
Just to block access to example.com/uploads/ you can place this rule in /uploads/.htaccess:
RewriteEngine On
RewriteRule ^/?$ - [F]
I would like to run a version of a Wordpress site on my localhost without going through too much hassle of changing url's, etc.
I have figured I will add a line in my hosts file to route domain.com to localhost. I just need a way to route / to look for files in /directory/directory/.
Thanks for any help.
Tried this, didn't seem to do anything:
RewriteEngine on
RewriteRule ^(.*)$ /directory/directory/$1 [L]
I used GasMask to route domain.com to my localhost.
Is it possible to force a 404 error if someone tries to access any directory in my root directory (/var/www) provided the directory name contains .git?
I.e if someone tried to access http://mysite.com/site.git, it would show a 404 page?
Furthermore, how could I prevent directory listing in the same file?
I am using Apache/2.2.22 (Ubuntu).
Thanks,
Max.
Using mod_rewrite, you can put these rules in the htaccess file in your document root:
RewriteEngine On
RewriteRule \.git$ - [R=404,L]
Or, you can replace the brackets with a [F,L] to return a 403 Forbidden instead.