I have spent a lot of time and read for the whole day to use htaccess in local host (Ubuntu).
I have folowed below steps.
1) Remove the '#' symbol from the line "AccessFileName .htaccess" File
: /etc/apache2/apache2.conf
2) changed, File : /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
3) Created a folder at the path /var/www/machine and placed two file index.html and demo.html
created a file .htaccess and the content of it is,
DirectoryIndex demo.html index.html
So, when I try to open the path localhost/machine it opens 'index.html' instead of "demo.html".
Also, when I have changed "AllowOverride None" to "AllowOverride All", I got a "you don't have permission to access localhost" error.
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 have two directories, using the first directory of (/var/www/html), my page is displaying perfectly after I include an index.html file. Then I created a second directory (/home/xsol/website) and created another index.html file. However, for the second directory, you will see a 403 forbidden error on the page even after I have given a chmod -r 755 to that file. My httpd.conf file is as below
<Directory "/home/xsol/website">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Try chmod -R 755 on the /home/xsol directory and add these settings to your new dir
Order allow,deny
Allow from all
Require all granted
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/
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