wamp local host .htaccess causing forbidden error? - php

I have been trying to rewrite the url.
Here is the content from my httpd.conf
<Directory "C:\wamp\www\base">
Options None
AllowOverride all
Order deny,allow
Allow from all
Satisfy all
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory C:\wamp\www\base>
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Options None
AllowOverride all
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
</Directory>
Error log from apache:-
error] [client 127.0.0.1] client denied by server configuration: C:/wamp/www/base/category
.htaccess file under base directory
Options +Indexes
Options +FollowSymLinks
RewriteEngine On
RewriteBase /base/
RewriteRule ^category /category.php
Before i was not doing url rewriting. If i remove .htaccess from base directory then it works fine.
so can anyone help me to enable url rewriting?

Related

Site deployment connection refused for Laravel Project hosted on EC2 instance

I'm trying to get my site deployed using Laravel on an AWS EC2 instance running CentOS7. I've checked to make sure the ports and traffic settings are correct and they are as I was able to hit the apache landing page prior to editing the conf and I am also able to ssh in and ping the IP, but I believe I am possibly having some issue with the config files. This is what I hit when I hit the endpoint:
My httpd is running and I was able to access the apache landing page prior to editing my config files.
Here is the main part of my httpd.conf (please note: I didn't include the whole thing because it is massive and consists of mostly commented out code):
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/[project_path]/public"
#
# Relax access to content within /var/www.
#
<Directory "/var/www/[project_path]/public">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/[project_path]/public">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
Require all denied
</Files>
and here is my added project.conf file inside of conf.d:
<Directory "/var/www/[project_path]/public">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/[project_path]/public">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
<Directory "/var/www/[project_path]/public">
Options -Indexes
</Directory>
<VirtualHost hostIP:80>
ServerName hostIP
DocumentRoot /var/www/[project_path]/public
TraceEnable Off
</VirtualHost>
ServerTokens Prod
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>
<IfModule mpm_prefork_module>
StartServers 50
MinSpareServers 10
MaxSpareServers 30
ServerLimit 50
MaxClients 50
MaxRequestsPerChild 100
</IfModule>
Any help would be greatly appreciated!
Your RewriteEngine is redirecting port 80 to HTTPS which goes to port 443 which is not defined.
If you want to run the server under port 80 (HTTP connection), remove the
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>
Resolved this by adding an ssl.conf file along with a project.conf.bak in conjunction with the project.conf file

Laravel document root Forbidden with HTTP 403 error

I have laravel instaled CentOS 7 server. PHP, MariaDB and HTTPD are installed and works. All services are up and works. Browse the document root shows
Forbidden
You don't have permission to access / on this server.
this is the document root of my server
DocumentRoot "/var/www/html/api/public"
Document root configurations
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
This is welcome.conf file ( /etc/httpd/conf.d/welcome.conf)
# This configuration file enables the default "Welcome" page if there
# is no default index page present for the root URL. To disable the
# Welcome page, comment out all the lines below.
#
# NOTE: if this file is removed, it will be restored on upgrades.
#
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
<Directory /usr/share/httpd/noindex>
AllowOverride None
Require all granted
</Directory>
Alias /.noindex.html /usr/share/httpd/noindex/index.html
Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png
What can I do for this issue?
Create and put this .htaccess file in your app folder.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
Below server configurations are fixed the issue with me.
Grant Folder Permission and Set ownership
chown -R apache:apache /var/www/html/laravel
chmod -R 755 /var/www/html/laravel/storage
Restore Security
restorecon -R /var/www
Disable SELinux
setenforce 0

android you don't have permission to access / on this server WAMP

im trying to open my wamp server with my android device but i get "android you don't have permission to access / on this server" apache version is 2.4.18.i tryed to modify httpd.conf but it doesnt work.Now its like this:
DocumentRoot "c:/wamp64/www"
<Directory "c:/wamp64/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Allow from all
</Directory>
I hope you can help me
For newer versions of WampServer (3.0+) you do not need to two things :
1) Modify the file httpd.conf
Go to directory where wamp is installed eg
C:\wamp64\bin\apache\apache2.4.23\conf and edit the following :
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options +Indexes +FollowSymLinks +Multiviews
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
#onlineoffline tag - don't remove
Require all granted
Edit Require none to Require all granted
2) Now go to C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhost.conf and do the same change to the Virtual Host defined for localhost
AllowOverride All
Require all granted
Restart the server it should work

Server-generated directory index forbidden by Options directive

I know this question has been asked a bunch of times but I'm not finding any answer that helps.
So I have two pages, index.php and refer.php. I put a rule into my httpd.conf that used mod_rewrite to get rid of the .php extension when a user goes to the page. Refer.php worked fine to show up as just refer, but trying to go to index.php gives me a Forbidden error.
Error log shows this:
AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive.
Here's the relevant part of my httpd.conf:
<Directory "/var/www">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
The file index.php exists, of course. Any help?
Edit:
The url is just the root url - like domain.com. It should access index.php, which it did fine before I did the mod_rewrite. So I expect the index page to come up, which it doesn't because of the errors that I described above. .htaccess file is just all defaults except for:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

You don't have permission to access /folder on this server - AWS EC2

I know that there are a billion questions about that, but I cannot make it work.
What have I done so far :
Change my httd.conf file so that the DirectoryRoot is /home/ec2-user/folder.
Restarted my apache server.
chmod -R 775 /home/ec2-user/folder
Changed my httd.conf (only the changed lines are in here)
...
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "/var/www/html"
DocumentRoot "/home/ec2-user/folder"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
# Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
# Allow from all
Require all granted
</Directory>
and then this :
# This should be changed to whatever you set DocumentRoot to.
#
#<Directory "/var/www/html">
<Directory "/home/ec2-user/folder">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
# Options Indexes FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
# Allow from all
Require all granted
</Directory>
and then this :
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
#Listen 80
Listen 0.0.0.0:80
But I still have permission denied on /file.php.
What am I missing?
EDIT : I have also changed the DocumentRoot. Before that, I had a wrong url error, now I do not have the permissions. So, right now, the url is correct, I just haven't set the correct permissions for it.
I didn't do something different from the above - but after restarting my Apache and exiting my AWS a number of times - then it magically worked. By following the above steps and checking the logs for errors, you should have it fixed.

Categories