I have just downloaded the latest version of XAMPP with PHP version 7.2.4. I have made a very simple PHP validation for a HTML form and when I press submit it comes up with the following:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
I'd don't know what the problem is as I have tried changing Require none to Require all granted.
Please Help!
I have experienced this problem and found out that localhost link is not configured in
httpd_vhosts.conf.
So I added this line at the bottom part of httpd_vhosts.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName localhost
</VirtualHost>
Well, probably this must be happening because the localhost link is not configured in your xamp vhost, try to look for the vhosts configuration file and add the same one there. Just add this block of code making the appropriate path changes until your repository so that you can access the localhost:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#hcode.com.br
DocumentRoot "C:\ecommerce"
ServerName www.hcodecommerce.com.br
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\ecommerce">
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>
</VirtualHost>
By default in httpd.conf your entire system directory "/" is secured and not allowed access
in httpd.conf:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
Add the below additional under the above
<Directory /home>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
Change /home to your hosted installation public directory - e.g. /projects or /devsite.local etc...
For more info on Apache see here: https://httpd.apache.org/docs/current/mod/core.html#directory
The 'Options' are typical .htaccess directives - change as needed
The 'AllowOverride All' gives access to the /home folder and everything under it
The 'Require local' makes sure only localhost / 127.0.0.1 has access to folder and files under /home
Hope this helps :D
Related
I have a problem with xampp etc. When I typing in URL address, for example, http://localhost/project/index.php/whatever.php server opened index.php with crashed style instead Not Found
The requested URL was not found on this server or something like that because /whatever.php does not exist in the project.
In console showed:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/project/index.php/style/style.css".
How I can prevent the open not existing path from my project ?
All versions of Apache allow this, it's normal... To solve your issue, please, edit your httpd.conf and where you have your VirtualHost config add this line:
AcceptPathInfo Off
Like here:
<VirtualHost localhost:80>
ServerName localhost:80
ServerAlias localhost
ErrorLog "${SRVROOT}/logs/localhost-error.log"
TransferLog "${SRVROOT}/logs/localhost-access.log"
DocumentRoot "D:/Web/www"
<Directory "D:/Web/www">
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AcceptPathInfo Off
AllowOverride All
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
</Directory>
</VirtualHost>
If not enough add this line to your .htaccess
################################################################################
######################### Remove /index.php/ from URLs #########################
################################################################################
RedirectMatch 301 ^/index\.php(/.*) $1
Hope this helps.
I have two different domains that are supposed to point exactly to the same index.php file:
diegodeoxossi.com.br
lumelivros.com.br
All DNS settings for both are the same. Apache default vhost is disabled and both domains has the same vhost configs, as below:
#1 diegodeoxossi.com.br
<VirtualHost *:80>
ServerName diegodeoxossi.com.br
ServerAlias *.diegodeoxossi.com.br
DocumentRoot /var/www/html
AllowEncodedSlashes On
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
SSLProxyEngine On
</VirtualHost>
#2 lumelivros.com
<VirtualHost *:80>
ServerName lumelivros.com
ServerAlias *.lumelivros.com
DocumentRoot /var/www/html
AllowEncodedSlashes On
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
SSLProxyEngine On
</VirtualHost>
They all point to the same root directory, and both pass by .htaccess - and here is the problem: my last line in .htaccess is:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* site/index.php?APPLR_friendlyURL=1 [L,QSA]
The thing is: domain #1 works great; domain #2 pass by this rule and keeps showing Apache's default page. Does any one have a clue on how to fix it?
ServerName lumelivros.com
You are missing the .br TLD that is present in the example, so the request will never match the stated VirtualHost. The request is likely being caught by the "default" vHost container and the expected .htaccess file is not even being processed.
Apache default vhost is disabled
You can't "disable" the default vhost. Whatever vHost is defined first is considered the default. So, there is always a default, even if you have not explicitly defined one.
However, as already mentioned in comments, if you want both domains to serve the same site (and the response is determined by the application) then you should only have a single vHost container that serves both domains.
For example:
<VirtualHost *:80>
ServerName diegodeoxossi.com.br
ServerAlias *.diegodeoxossi.com.br
ServerAlias lumelivros.com.br
ServerAlias *.lumelivros.com.br
:
Aside:
RewriteEngine on
SSLProxyEngine On
These two directives are out of place here. (?)
I am trying to configure a Wordpress project on my localhost, but when I open the browser on localhost I only see the files in the root of my wordpress project.
If I click on index.php or access localhost/index.php it executes the PHP as expected.
I have installed apache 2.4, php 7.2 and php-apache 7.2.
My project is in /srv/http/mysite:
The relevant lines in /etc/httpd/conf/httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Note: Since httpd.conf is very big I showed only the lines I know to be relevant. If this is not enough I can upload the entire file on pastebin.
The file /etc/httpd/conf/extra/httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster#test.localhost
DocumentRoot "/srv/http/mysite/"
ServerName test.localhost
ServerAlias test.localhost
ErrorLog "/var/log/httpd/test.localhost-error_log"
CustomLog "/var/log/httpd/test.localhost-access_log" common
<Directory "/srv/http/mysite/">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
The file /srv/http/mysite/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
My /etc/hosts file:
127.0.0.1 localhost
127.0.1.1 mycomputer_name
127.0.2.1 test.localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
About this last file I noticed that if I remove the <IfModule ...> and </IfModule> site it works and redirects to index.php, but I would prefer not to change this file since it works the way it is on the remote server that uses ubuntu.
The main question is why this is not working but I would be also happy to know what the <IfModule mod_rewrite.c> is doing and why it is being ignored even though LoadModule rewrite_module modules/mod_rewrite.so is enabled.
I know this is not an easy question but I have not found anyone with this same problem on the web. I will be very grateful for any help.
Apache needs to be setup to recognize your index files (in this case index.php)
Do you have the following in your Directory
DirectoryIndex index.php
So
<Directory "/srv/http/mysite/">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
In httpd.conf you should have something like...
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
This would be your catch-all fall-back.
And then in your httpd-vhosts.conf one of many site descriptions might look something like...
<VirtualHost *:8080>
ServerAdmin admin#siteName.com
DocumentRoot "e:/Stack/Sites/siteName/web"
ServerName siteName
ServerAlias siteNameUser
<Directory "e:/Stack/Sites/SiteName/web">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/siteName.error.log"
CustomLog "logs/siteName.access.log" common
</VirtualHost>
Note: The DirectoryIndex index.php in httpd-vhosts.conf site declaration is unnecessary if you included the fall-back defaults in httpd.conf
If you are not wanting to use default port 80 then in either file have something like: Listen 8080
For localhost I use: in httpd.conf... Listen 127.0.0.1:8080 and in httpd-vhosts.conf Listen 8080
In your hosts file you will need to define something like...
127.0.0.1 siteName siteNameUser www.siteName.com
Currently using: Apache/2.4.33 (Win64) PHP/7.2.4 ~ MySql 5.7.22 homebrew stack.
The httpd-vhosts.conf example portion is for Drupal 8.x - For WP your DocumentRoot and Directory will differ.
You can listen on multiple ports such as 8080 for dev, 8081 for test, 8082 for prod. Also you can have many different site definitions in your httpd-vhosts.conf file.
I prefer to define all sites in httpd-vhosts.conf, but you could just place them in httpd.conf
I'm having a problem auto loading index.php in subdirectories with Apache2.
This is what I see in browser console when connecting:
GET http://example.com/login HTTP 301 Moved Permanently
GET http://10.0.3.10/login/
Connection Timed Out
When I type in http://example.com/login/, it works as intended. Also,
Root directory redirects to index.php properly.
I'm fairly new to this topic, would appriciate any help.
Default virtual host settings:
#NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName example.com/
ServerAlias www.example.com/
DocumentRoot /var/www/example.com/
<Directory />
AllowOverride All
DirectoryIndex index.php
</Directory>
<Directory /var/www/example.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
...
httpd.conf:
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
No .htaccess file used.
I think your request is handled by a virtualhost with no ServerName, and at startup httpd probably warns you that it can't find a default hostname for your local IP (10.0.3.10)
Try removing the trailing slashes from your ServerName and ServerAlias. You will need to do even more if your ServerName or ServerAlias matches the systems hostname -- namely adding a dummy ServerName to your default vhost.
I keep trying to configure it so that the domain symfony.local would link to the app_dev.php, but I also keep getting forwarded to the xampp page.
My hosts file is:
127.0.0.1 symfony.local
My httpd-vhost is:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName symfony.local
DocumentRoot "C:\xampp\htdocs\testAS\web"
DirectoryIndex app_dev.php
<Directory "C:\xampp\htdocs\testAS\web">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
I'm using Windows 8. Appreciate any feedback.
I assume it's a fairly recent version of xampp? There is a new directive "Require local" that popped up a few years ago. I remember being stumped by it.
<Directory "C:/home/ahundiak/zayso2016/cerad3/web">
## Options Indexes FollowSymLinks
AllowOverride All
Require local ## Add This
</Directory>
<VirtualHost *:80>
ServerName local.api.zayso.org
DocumentRoot "C:/home/ahundiak/zayso2016/cerad3/web"
</VirtualHost>
I am not an expert on configuring this. The above works for me using the Symfony 2 .htaccess file.
may be it issue of your hosts file entry of symfony.local and local ip address or may between them only TAB(on keyboard) require ...
OR if above answer not work follow below
please follow this link Click Here it help you solve your issue of not show symfony project