I have a problem with a .htaccess file not being read by Apache. I'm using it on my local machine, port 81. I'm using Windows 10.
I created a .htaccess file in the root directory of my .php files.
When I enter some rubbish inside .htaccess file nothing happens (website loads normally). I've checked many tutorials, threads and was unable to find a viable solution.
What I have done so far:
Entered anything in the .htaccess file to check or the 500 error (didn't work)
Checked the httpd.conf file for AllowOverride All (for directory as well)
Re-installed Xampp
This is how my settings in httpd.conf look like now:
#
# 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.
#
<Directory />
AllowOverride All
# Require all denied
</Directory>
I've got no idea what to do next. Any ideas?
Is this section in httpd.con like this, or is looking for any other file name?
#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess
Related
I have been struggling with setting up a PHP/MySQL environment all day and thought I would finally ask for help.
I have XAMPP up and running. In order to work in my preferred directory I've updated /Applications/XAMPP/xamppfiles/etc/httpd.conf with:
User MY_USERNAME
...
DocumentRoot "/Users/PATH/TO/WORKING/DIR/web"
<Directory "/Users/PATH/TO/WORKING/DIR/web">
#
# 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/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes
#
# 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
# since XAMPP 1.4:
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
Otherwise my httpd.conf settings are the XAMPP defaults. In my web dir, I have index.php:
<?php
require_once __DIR__."/../vendor/autoload.php";
$app = new Silex\Application();
$app->get("/", function () {
return "Hello World";
});
$app->get("/test", function () {
return "Success";
});
$app->run();
?>
If I go to localhost, I get the expected "Hello World." However, if I go to localhost/test I get:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.23 (Unix) OpenSSL/1.0.2h PHP/5.6.24 mod_perl/2.0.8-dev Perl/v5.16.3
This is a much simplified example, but illustrates the problem.
I've scoured the Google results for this error, but none of the recommended suggestions have helped:
Lots of people suggest I update .htaccess, but I don't know where that is in XAMPP or where I should create it or what I should put in it or what it is.
Recommendation of changing AllowOverride None to AllowOverride All in httpd.conf didn't seem to work. (I reverted this back to the default settings after confirming that it didn't help)
Any help would be appreciated! Thanks for your time!
SOLUTION
I had created .htaccess in /Users/PATH/TO/WORKING/DIR/todo where I needed to put it in /Users/PATH/TO/WORKING/DIR/todo/web where I was pointing XAMPP to. Then inside of .htaccess I put the stuff Silex told me to put in there: http://silex.sensiolabs.org/doc/master/web_servers.html
.htaccess needs to be at the root of your web application, so in web. Create it if it doesn't exist. It should contain what's indicated here http://silex.sensiolabs.org/doc/master/web_servers.html
AllowOverride All is indeed needed but if you don't have any .htaccess file in your web app folder, there's 0 chance it's gonna work.
Yesterday I upgraded to Yosemite and now my local configuration for web development is not working anymore.
I managed to set up a userdir under /Users/user/public_html and I could access all the websites via localhost/~user/websitename. Nothing special, but it took me a while to configure.
Looking in the apache directory I saw that many files were replaced, keeping a backup. I tried putting back the files with my settings again, but still is not working. Maybe I'm missing some file that I don't remember.
This is httpd-userdir.conf:
# Settings for user home directories
#
# Required module: mod_userdir
#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received. Note that you must also set
# the default access control for these directories, as in the example below.
#
UserDir public_html
#
# Users might not be in /Users/*/Sites, so use user-specific config files.
#
Include /private/etc/apache2/users/*.conf
<IfModule bonjour_module>
RegisterUserSite customized-users
</IfModule>
<Directory "/Users/*/public_html/">
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
</Directory>
Then in http.conf I have enabled some modules:
Include /private/etc/apache2/extra/httpd-userdir.conf
LoadModule userdir_module libexec/apache2/mod_userdir.so
and this:
DocumentRoot "/Users/user/public_html"
Directory "/Users/user/public_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.2/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:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
If I simply try to access localhost, it displays the message "It works!". If I go to localhost/user simply doesn't load and the same if I try to access one of the websites.
Did I miss any file? In the apache logs it doesn't even display any error.
OS X 10.10 Yosemite comes with Apache 2.4 instead of Apache 2.2 in Mavericks.
The major difference in configuration is that you have to replace...
Order allow,deny
Allow from all
...with...
Require all granted
See Apache doc's manual Upgrading to 2.4 from 2.2 for more details.
UPDATE:
Please be aware that after upgrading OS X you will usually find your old config files as backups next to the new ones written by Yosemite. They are labeled e.g. httpd.conf.pre-update and/or httpd.conf~previous and can be found in the same paths as the new configs (e.g. in /private/etc/apache2).
After attempting to fix this problem for 6 hours I was finally able to get this to work. I edited the httpd.conf, httpd-userdir.conf, httpd-vhosts.conf, etc to no avail. Leaving all of these files unedited from the yosemite configuration, what finally worked for me was to edit the httpd_server_app.conf located at /Library/Server/Web/Config/apache2/ by adding the following (for each site) as follows:
<Directory />
Options +FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
<Directory "/Library/Server/Web/Data/Sites/Default/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/Library/Server/Web/Data/Sites/[OTHER SITE DIRECTORY]/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Make sure if you use textedit to edit this file you undo the automatic insertion of the slanted quotation marks otherwise you will get a unicode error message.
Hope this helps!
I am attempting to solve an error with my error, I am unable to connect from the server to my android application.
All sources are pointing me towards the following tutorial as the solution.
I have completed all steps in the tutorial successfully apart from:
Edit httpd.conf file of Wamp server
I.e. the tutorial instructs the following:
4 .Find this section of configuration within the httpd.conf file:
Directory “c:/wamp/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.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
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Now Find and replace ’127.0.0.1′ with ‘All’, save the file and restart your wamp server.
However, my issue is that I do not have this code within my httpd.conf file. My corresponding section looks like this:
<Directory "c:/wamp/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
Require all granted
</Directory>
What can I change within my code to solve this?
A solution would be greatly appreciated, I have now been stuck with server issues for over a week :(
Know this is old, but it could save someone the stress I went through trying to fix the "Forbidden-Kingdom-Error" that got me twerking my fingers on google... thats the 403 error incase you mistakenly think you have no idea what I'm talking about. and if you do thats simply Awesome and way Hot!
*click on the WAMP server icon on the system tray(I am assuming you're using windows) and then ->Apache-> httpd.vhosts.conf [open the "httpd.vhosts.conf" file]
*and change "Require local" in the Directory tag( ...) to "Require all granted"
.This should be the bomb you're looking for!
*click the WAMP icon again and Restart all services then put Online finally. FINALLY and extra FINALLY you are good2 go!
N.B
This should definitely work 4 you especially if after following online-tutorials on how to connect your Android device to your Wamp server by modifying your firewall settings(i.e by adding a new rule) and modifying the httpd.conf file as instructed and you are still getting the "Forbidden error" codename-403.
I have installed Apache successfully on WINDOWS and can open an HTML file with no issues. I also installed PHP on the server. I configured Apache and PHP as per the followng tutorials:
http://www.sitepoint.com/how-to-install-apache-on-windows/
http://www.sitepoint.com/how-to-install-php-on-windows/
As mentioned apache allows me to open the html file in my website. when adding a php file I get error:
You don't have permission to access /php/php-cgi.exe/index.php on this server.
PHP is installed to c:\PHP and apached in c:\apache24
I have tried a few options to fix the https.conf file but without any success.
My config file snippet is below:
<Directory "c:/WebPages">
#
# 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 None
#
# Controls who can get stuff from this server.
#
##Require all granted
#Options FollowSymLinks
AllowOverride None
Options None
Require all granted
Allow from all
</Directory>
This allows me to view the html file but not the php so am thinkign I need to allow permission to the c:\PHP folder but have no idea what?
any advice welcome. Thanks as always.
This happens because your CGI folder isn't at your PHP install folder. Try adding these lines of code to your httpd.conf file:
<Directory "c:/php">
AllowOverride None
Options None
Require all granted
</Directory>
If you didn't install PHP at c:\php, change that to wherever you installed it. Remember, use forward slashes instead of back ones (I always get mixed up with that; to much Linuxing I guess).
I have several sites setup on my local machine - customerappglobal, customerapp and naturaleigh. I have just one - customerappglobal - working at the moment because thats the only one I need working. I have added the following code to my httpd.conf file:
<VirtualHost *:427>
# The name to respond to
ServerName customerappglobal
# Folder where the files live
DocumentRoot "C:/HeritageApps/CustomerApp_v2"
# A few helpful settings...
<Directory "C:/HeritageApps/CustomerApp_v2">
allow from all
order allow,deny
# Enables .htaccess files for this site
AllowOverride All
</Directory>
# Apache will look for these two files, in this order, if no file is specified in the URL
DirectoryIndex index.html index.php
</VirtualHost>
<Directory "c:/HeritageApps">
#
# 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
#Allow,Deny
Order Deny,Allow
Allow from all
</Directory>
This appears to be enough for it to work (oh and a line added in the HOSTS file..).
Anyway I am using wampserver (the latest one) with PHP 5, Apache and mySQL. The site loads fine unless I use a relative path for require_once in the file I am trying to load.
I get the following error:
Warning: require_once(/vars.inc)
[function.require-once]: failed to
open stream: No such file or directory
in
C:\HeritageApps\CustomerApp_v2\Customers\Customers.php
on line 2
Fatal error: require_once()
[function.require]: Failed opening
required '/vars.inc'
(include_path='.;C:\php5\pear') in
C:\HeritageApps\CustomerApp_v2\Customers\Customers.php
on line 2
As far as I know the include path (C:\php5\pear) does not exist and I cannot find any trace of that path in the php.ini file or the httpd.conf files. I have read that the non-existance of the path is why it is throwing the error, but I have not found any solutions. This has been happening for the past day or two and I tend to suffer from the curse of getting wound up and angry if something doesnt work for too long - so please could someone help me with this? I really dont know what is going wrong or where it is going wrong... I have searched everywhere that I can think of. I just need to be able to change the include path for all the applications individually (or changing it globally would be a brilliant start!!).
The problem is your include: Warning: require_once(/vars.inc), where / relates to the file system root. What you really want is either require_once('./vars.inc'); or require_once('vars.inc');.