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 ???
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.
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
OK I am new to ASKING questions on stackoverflow, but I need to get this figured out. I have a VPS with Apache installed Running Ubuntu 12.04 LTS. I downloaded a php script which required php 5.4+ but I had 5.3 installed. Then I followed the instructions located at this link.
While doing the upgrade, the installer told me that my php.ini file was manually changed. I believe I did this in order to view the errors on screen with the "display_errors=on" variable a long time ago. I therefore selected the option to KEEP and USE the old version of php.ini. Once the installation was done and the apache server restarted. I went to my chrome browser and pressed "refresh" and to my dismay, "403 Forbidden".
Here is the conf file for the virtual server:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/{usr}/Public/
# Indexes + Directory Root.
DirectoryIndex index.html index.shtml index.php
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /home/{usr}/Public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/{usr}/Public/log/{server}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/{usr}/Public/log/{server}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I obscured the username to {usr} and the folder to {server} to keep anonymity. This file was created BY ME, by putting it together with some other example file. I'm not sure if this is correct, all I know is that before this upgrade, everything was working fine!
I also "LL"'d the "Public" folder and here's what I found:
drwxrwxrwx 28 {usr} {usr} 4096 Sep 4 01:09 Public/
It seems that all the folders under it have the same permission. Please help and if there are any questions, feel free to ask. I've been doing this for many years but by no means would I call myself an "expert".
Thanks in advance.
Did you also upgrade Apache 2 ?
Apache 2.4 has a new user rights policy system : http://httpd.apache.org/docs/2.4/upgrading.html#run-time
Hi Friends previously I am using XAMP Server but when I install joomla Templates it creates alots of error. Now I installed the WAMP, but the issues are:
1. I can access with 127.0.0.1, but I cant access with "localhost".
2 When i access phpmyadmin i get this error.
Forbidden You don't have permission to access /phpmyadmin/ on this server.
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin3.4.5/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
#
# by
#
# Order Allow,Deny
# Allow from all
#
After changing, it will look like this
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
After this just restart Wamp
Go to C:\wamp\alias. Open the file phpmyadmin.conf and change
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
to
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
problem solved
Change httpd.conf file as follows:
from
<Directory />
AllowOverride none
Require all denied
</Directory>
to
<Directory />
AllowOverride none
Require all granted
</Directory>
So none of the above stuff worked for me. Except this:
edit httpd.conf,
find the line
Listen 80
and change to
listen 0.0.0.0:80
if you are running windows 8, its got something to do with using ipv6 instead of ipv4
Go to C:\wamp\alias.
Open the file phpmyadmin.conf and add
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from MACHINE_IP
Change in following file \bin\apache\apache2.2.22\conf\httpd.conf
Replace Listen 80 with Listen 0.0.0.0:80
Replace
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
with
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
Replace
onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
with
onlineoffline tag - don't remove
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
in \wamp\alias\phpmyadmin.conf
replace
<Directory "c:/wamp/apps/phpmyadmin3.4.10.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
with
<Directory "c:/wamp/apps/phpmyadmin3.4.10.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Directory>
Tested on windows localhost.
Note : Please consider RigsFolly's comment also.
For WampServer 2.2 with Apache 2.4.2 I ended up with:
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require local
To solve this, I opened httpd.conf and changed the following line:
Allow from 127.0.0.1
to:
Allow from 127.0.0.1 ::1
I faced this problem
Forbidden You don't have permission to access /phpmyadmin/ on this server
Some help about this:
First check you installed a fresh wamp or replace the existing one. If it's fresh there is no problem, For done existing installation.
Follow these steps.
Open your wamp\bin\mysql directory
Check if in this folder there is another folder of mysql with different name, if exists delete it.
enter to remain mysql folder and delete files with duplication.
start your wamp server again. Wamp will be working.
just add following line in wamp/alias/phpmyadmin.conf
Allow from ::1
so it will look something like this depending your phpmyadmin version.
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Directory>
If its possible uninstall wamp then run installation as administrator then change you mysql.conf file like that
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
Allow from all
</Directory>
Not: Before I reinstall as admin the solution above didn't work for me
Change the file content of c:\wamp\alias\phpmyadmin.conf to the following.
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
Here my WAMP installation is in the c:\wamp folder. Change it according to your installation.
Previously, it was like this:
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
Restart your Apache server after making these changes.
In your apache config file (../bin/apachex.y.z/cong/httpd.conf)
Just change
< Directory "c:/wamp/www/" >
...
...
"Require local" ===> "Require all granted"
< /Directory >
This allows other pc's to access (to read) your web folder.
I had done below changes for new phpmyadmin4.0.4 in httpd.conf file
<Directory />
AllowOverride none
Require all granted
</Directory>
and phpmyadmin.conf
<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
and restart my server.
None of the above answers worked for me, or where unsafe (as some pointed out, using Allow from all can make your files and data accessible to the outside world).
Open the c:\wamp\alias\phpmyadmin.conf file and change
Allow from 127.0.0.1
to
Allow from 127.0.0.1 ::1
Explanation:
On most computer systems, localhost resolves to the IP address 127.0.0.1, which is the most commonly used IPv4 loopback address, and to the IPv6 loopback address ::1 (source: https://en.wikipedia.org/wiki/Localhost)
The resolution of the name localhost into one or more IP addresses is configured by the following lines in the operating system's hosts file:
127.0.0.1 localhost
::1 localhost
to see your hosts file, go to c:\Windows\System32\drivers\etc\HOSTS
notice the above lines are commented out with the note: # localhost name resolution is handled within DNS itself.
On my machine, on Win7, I also noticed the following:
localhost\phpmyadmin did not work on Chrome, but worked on IE11
127.0.0.1\phpmyadmin worked on Chrome
comment Require local from httpd.conf
"#Require local"