There is my problem, i have an img tag, src gets image from icon/ folder and i need to disable direct link access to that folder and content inside that when user type something like 'mywebsite.com/icon/logo.png', using htaccess, but allow content inside src attribute to get and display it without 403 error message 'access denied' in browser console, i made lot of research but nothing helped me, if i missing something please provide your opinions thanks.
my .htaccess code is here:
<IfModule mod_rewrite.c>
<If "%{HTTP_HOST} == 'http://mywebsite.com/icon/'">
deny from all
</If>
<Else>
allow from all
</Else>
</IfModule>
The best way to do this is disable it with webserver apache2. In my 14.X Ubuntu - open /etc/apache2/apache2.conf you have to change from
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
now just restart apache.
to restart apache2 run:
sudo service apache2 restart
This will disable directory listing from all folder that apache2 serves.
Related
I'm trying to use .htaccess on my project on apache2 using ubuntu 18.04.
The tutorials I saw said that I have to change apache2.conf as:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all denied
</Directory>
To:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all denied
</Directory>
After change it, I make my own htaccess on project but it doesn't work.
I want browser prevent user to go backward and browsing project directories and my computer directories using URL ../../../../
Ex: localhost/project/index.php/../../../../
How can I use my .htaccess in my project?, knowing that there is no default .htaccess file !
And how to prevent user for browsing directories using ../../ in url ???
I am running a CentOS 6.9 OS. I have Apache/2.2.15 (CentOS) Server running. I have a cakephp 2 application that I want to run here. I have an index.php file inside /var/www/html that runs perfectly. I have another folder called test inside /var/www/html.
Inside that folder there is an index.php file. Test folder also runs perfectly. But whenever I try to run the cakephp application from the browser I get the message I don't have permission to access that folder. The cakephp application has 0777 permission. Inside my /etc/httpd/conf/httpd.conf file there is written -
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
So I don't know what I am doing wrong and what more I can do.
hi dude please find and edit httpd.conf file, which is in /etc/httpd/conf/httpd.conf. and paste the code below
<Directory "/">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
<Directory "/home/">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
Then kindly restart the server if the problem still appear
disable the seLinux in /etc/selinux/config change SELINUX=disabled and restart the server it again hope it works now ^_^
restorecon -r /var/www/html does the job
I got the answer from here. https://www.centos.org/forums/viewtopic.php?t=6834
I'm facing the following message when I visit my website:
You don't have permission to access /index.php on this server.
I am able to visit my other website in same URL, as in http://xiukun.wang/scrapy/, but http://xiukun.wang/datavis/ doesn't work.
I have tried many methods to solve it, like editing my httpd.conf file, however it doesn't work. How do I solve it?
<Directory "/alidata/www">
AllowOverride none
Require all granted
</Directory>
DocumentRoot "/alidata/www"
<Directory "/alidata/www">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
Have you changed anything in your .htaccess file? Also did you change anything in config file such as DB name user and pass?
Also update the permissions to 755 of your public_html.
EDIT
Since you specified its apache, try these solutions:
Can you open your APACHE config file and find out the index name?
Check your Directive DirectoryIndex and make sure your index is listed, or else upload:
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
Check for correct dir permissions:
<Directory "/home/domain/www">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
Modify file system permissions of Home directory that APACHE is
installed:
#chmod a+x /apache-home-dir-of installation
Make sure the CGI script requested have executable permissions set on
files. Use chmod command to set permission:
$ chmod +x file.cgi
Check APACHE logs for errors:
# tail -f /path/to/apache/error.logs
Source: https://www.cyberciti.biz/faq/apache-403-forbidden-error-and-solution/
I am using PHP 7.0.5 and Apache 2.4.20 and I would like to run Squirrelmail.
I am getting a 403 Forbidden error when I try to access any of the squirrelmail pages like HostName/squirrelmail, HostName/squirrelmail/src/login.php or HostName/squirrelmail/src/configtest.php ect.
In my httpd.conf I have:
Alias /squirrelmail /usr/local/squirrelmail/www
<Directory /usr/local/squirrelmail/www>
Options None
AllowOverride None
DirectoryIndex index.php
Order Allow,Deny
Allow from all
</Directory>
This is due to httpd 2.4 access control has changed from the previous version
the solution is as follows
Order allow,deny Allow from all
should be replaced by:
Require all granted
then restart httpd
systemctl restart httpd
You must check the log of Apache to solve the problem, in centos 7 the logs will be in tow pathes:
/var/log/httpd/error_log
Or
/var/log/httpd/ssl_error_log
In generally Apache vhost.conf file must contain this lines:
Alias /webmail /usr/share/squirrelmail
<Directory "/usr/share/squirrelmail">
Options Indexes MultiViews
Require all granted
AllowOverride none
Order allow,deny
Allow from all
Options +SymLinksIfOwnerMatch
DirectoryIndex index.php index.html index.htm
</Directory>
My codeigniter project was running successfully without index.php in url. It all started after I upgraded to php 5.6 from 5.4 . During upgradation I have faced several issues regarding apache which I resolved successfully one by one due to which my project is successfully running now but all its asking is index.php in url.
My attempts:
1.I have checked the mod rewrite and enabled it
2.not changed .htaccess content in my project root as it already contains the code to bypass index.php from url
3.I have tried to replace the blank file httpd.conf with
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory><Directory>
AllowOverride All
</Directory>
4.$config['index_page'] = ''
5.In /etc/apache2/sites_available/default I have
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Please help me!
May be rewrite mod is not enabled
Execute this in terminal
sudo a2enmod rewrite
sudo service apache2 restart