in my apache sites-available/default file i had change the config to folowing:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All //originally was AllowOverride None
FallbackResource rewrite.php //i added this line, too
Order allow,deny
allow from all
</Directory>
i wanted to handle all url calls in my own rewrite.php file. this works, when i visit my site at http://192.168.1.104:4567/web/knxzkcha but doesnt work when i go for http://192.168.1.104:4567/web/. i got this problem in firefox : The connection to the server was reset while the page was loading.
the index site http://192.168.1.104:4567/web/index.php works flawlessly and shows me my index.php file. all i want is to let me show the index file when visiting the root directory, too. /var/www points to the /web directory. i have some ubuntu 12.04 server 64 LTS edition
when i rewert the config lines, the root gives me the index file by default.
You do not need to add AllowOverride All, telling apache to avoid IO by checking existence of .htaccess files in current directory and all parents directories with AllowOverride None is a good recipe for speed. Avoid .htaccess files if you can edit Apache configuration.
Now FallbackResource is a quite new feature and may have some bugs. Did you check the ErrorLog for details? Could you try that with LogLevel debug?
It seems you problems is with directories, maybe you could fix it by enforcing usage of your fallback when a Directory is requested, try to add:
DirectoryIndex rewrite.php
Related
I'm running an Apache server on my computer through MAMP, and I can't seem to get it to read my .htaccess file. All of the solutions I've looked at have said to make sure that my AllowOverride is set to All in httpd.conf, which it is, but this doesn't seem to resolve my issue. I know that .htaccess isn't being read since I've written some nonsense at the start of the file and no error is being produced. I have also restarted the Apache servers after changing httpd.conf. Maybe the problem is that I'm not completely sure where I'm supposed to place the .htaccess file.
My MAMP document root was formerly MAMP > htdocs, but I changed it to Library > WebServer > Documents, which is where all of my PHP files are located. The current project I'm working on is a subdirectory of this, say Library > WebServer > Documents > project. This is the folder that contains my .htaccess file. My httpd.conf file is in MAMP > conf > apache, and the relevant section of it is as follows:
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Do I need to change the directory from / to something else to get this working? Any help is really appreciated.
Edit: I added the following <VirtualHost> block to my httpd.conf following the comments below, but again, nothing seems to change:
<VirtualHost *:80>
ServerAdmin email#site.com
ServerName localhost:8890
DocumentRoot /
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Update (Solved): I was able to resolve the issue by reverting MAMP's DocumentRoot to its original MAMP > htdocs as opposed to my Library > WebServer > Documents. Apache is now reading the .htaccess file located in my MAMP > htdocs > project. Thanks everyone for the help.
First I would try to fix my VirtualHost to use the correct paths. I'm not super familiar with Mac, but if Library > WebServer > Documents > project corresponds to /Library/WebServer/Documents/project in your file system, then I would use that. Might be /home/your_username/Library/WebServer/Documents/project but as I said, I'm not a Mac guy. Next, I don't understand why you have directives for the same directory with opposite permissions, so I would try to remove the first Directory block or change the targetted directory to something else on one of the blocks. Note that you should never grant access to / with apache as it would be a very big security breach.
<VirtualHost *:80>
ServerAdmin email#site.com
ServerName localhost:8890
DocumentRoot /Library/WebServer/Documents/project
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory /Library/WebServer/Documents/project>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
If it still doesn't work, you might want to make sure that the filename Apache is looking for hasn't been changed to something else using the AccessFileName directive.
Also, you are not giving details on where you put the VirtualHost block, but if it is in a separate file. Make sure you are including that file somehow.
You don't specify your Apache version but since version 2.4, you should Require instead of Allow directives since this is deprecated. See https://httpd.apache.org/docs/2.4/en/howto/access.html
Try adding Listen 80 and Listen 443 to the top of the main config.
Check your httpd.conf. Via the AllowOverride (http://httpd.apache.org/docs/current/mod/core.html#allowoverride) and AllowOverrideList (http://httpd.apache.org/docs/current/mod/core.html#allowoverridelist) directives it can control whether or not .htaccess files are considered.
When this directive (i.e. AllowOverride) is set to None and AllowOverrideList is set to None, .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.
Please note that the default value is None for both, which cause exactly this behavior of not considering .htaccess files.
I have a page :
http://domain.com/index.php
But strangely, the following urls are also working and rendering the same page :
http://domain.com/index.php/abcd
http://domain.com/index.php/gefe
and so on..
Clearly, it seems to be a screwed up regex config. But strangely, the urls continue to work even when I deleted my .htaccess file.
Now, I can only blame my apache config for this but everything seems as expected.
My apache config :
<VirtualHost *:80>
# Server name
ServerName domain.com
# Document root
DocumentRoot /path/to/source
<Directory />
Options FollowSymLinks
</Directory>
<Directory /path/to/source>
AllowOverride All
Options Indexes FollowSymLinks MultiViews
Order allow,deny
allow from all
</Directory>
LogLevel error
# Logs
ErrorLog ${APACHE_LOG_DIR}/domain_error.log
CustomLog ${APACHE_LOG_DIR}/domain_access.log combined
RewriteMap lc int:tolower
</VirtualHost>
Can anyone point out the mistake ?
It's called PATH_INFO. Apache will scan a URL from left-to-right. As long as it finds directories that match, it'll keep doing down the document root, until it either runs out of directories, or hits a script that matches. After that, any extra "path" information becomes PATH_INFO, e.g.
you have a site with a script called 'foo.php' in a really-does-exist dir structure of /a/b/c, so that
http://example.com/a/b/c/foo.php
is a valid url.
IN that case,
http://example.com/a/b/c/foo.php/bar/baz/bip/bop/boop
^^^^^^^^^^^^^^^^^^^^^-- path info
Read up: http://httpd.apache.org/docs/current/mod/core.html#acceptpathinfo
Adding to a URL like that is perfectly legitimate - the extra path is available to your PHP code in $_SERVER['PATH_INFO'].
It's not that different to saying http://domain.com/index.php?ab=cd, just a different way to add further information to a URL.
I am not sure why this is happening as I am not very knowledgeable when it comes to Apache. Below is a copy of my VirtualHost.
If this gives any extra help as to how to get it to work, I am trying to run a CakePHP site. I know the site itself has no issues as I have another location I manage the code from and can get it running locally through Apache there.
<virtualhost *:80>
DocumentRoot "C:/sites/sitename"
ServerName dev.sitename.com
ErrorLog "logs/sitename.com-error.log"
CustomLog "logs/sitename.com-access.log" common
<directory "C:/sites/sitename">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</directory>
</virtualhost>
I am running this on Apache 2.0 and Win7sp1
UPDATE
I never found the real solution using the route I was on. I downloaded a fresh copy of WAMP and was soon able to get everything up and running, no problem.
In order to prevent apache from showing the directory listing, you need to disable indexes. Also, it's best to disable MultiViews as that will enable content-negotiating, which may produce unwanted side-effects
Change the options to;
Options -Indexes FollowSymLinks
Then, check that the .htaccess file is present inside your webroot (C:/Sites/Sitename), as that file is used to enable mod_rewrite
Additional pointers/hints
First of all, make sure that the DocumentRoot is pointing to the right directory of your application;
The standard directory structure of CakePHP looks like this;
app
/Config
/Controllers
/Views
......
/webroot
lib
/Cale
plugins
The DocumentRoot should point to your `app/webroot' directory, which contains all 'public' files.
Change the paths/directories in your virtual host to that directory and restart Apache.
If you're still getting a 403 error, change the URL you're visiting in your browser to this;
http://mywebsite.com/index.php
If this does work, check if the .htaccess file is present in that directory and mod_rewrite is installed in your Apache.
According to the answer from "thaJetzah" (sorry, can't comment yet:) )
403 Forbidden is better than having the index of the folder, because now you can see the logs/sitename.com-error.log log and hopefully it tells you, why it gives 403.
Just to make sure: The index.php is in the folder "C:/sites/sitename"?
If you can't isolate the error like this, it would be great to post here the output of the error.log when you try to access the page and it gives you 403.
Check this If you are running Ubuntu.
I have built a Zend Framework application. By configuring it to read routes.ini file, my application after deployment is not going to any routes but only default route is working. I have total of 4 routes in this application and none of them are working. Apache is showing a Not Found error.
I had look at .htaccess file it is perfect and in my local it is working fine. I also checked the permissions. It is having read and write rights for www-data. I also checked Apache URL rewrite module.
I did this again and tried:
sudo a2enmod rewrite
Still same issue.
My apache error log says that file does not exist.
Please tell me where I have gone wrong.
After researching for hours , I could notice that there was a very minor and sensitive mistake in the apache vhost file .
my entry was like this
<Directory /var/www/your_project>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
But actually my entry should be as per mssb some what like this
<Directory /var/www/your_project>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory
Since I am not an experienced webmaster I couldn't noticed one simple thing which is
AllowOveride option which was set to None
I referred to Core apace documentation today in order find where I was wrong .
The reason for not picking .htaccess file is as follows
When AllowOveride directive is set to None, then .htaccess files are
completely ignored. In this case, the server will not even attempt to
read .htaccess files in the filesystem.
When this directive is set to All, then any directive which has the
.htaccess Context is allowed in .htaccess files.
I personally felt like Posting this entire solution for the problem to help others who may face a similar problem in future
Once again I would like to thank you all for responding to this post
Try following steps to mod_rewrite
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
sudo gedit /etc/apache2/sites-enabled/000-default
add following codes
<Directory /var/www/your_prject_name>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
</Directory>
then restart the server
sudo /etc/init.d/apache2 restart
I have installed XAMPP in my machine(Windows XP OS). And I have Eclipse as IDE.
Now my question is, In which directory i should keep my workspace (or project).
Whether I should keep under the path "C:\xampp\php\www" OR under "C:\xampp\htdocs".
You need to change the DocumentRoot value in c:\xampp\apache\conf\httpd.conf from
DocumentRoot "C:\xampp\htdocs"
to
DocumentRoot "E:/MyProject/Source/Admin"
and configure permissions also.
<Directory "E:/MyProject/Source/Admin">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
and then restart the apache server(in xampp control panel). so from there onwards whenever you access http://localhost/ it will execute the files under E:/MyProject/Source/Admin
see for more info.
http://httpd.apache.org/docs/2.0/mod/core.html#documentroot
http://www.apachefriends.org/en/xampp-windows.html#529
Looking at the Where I change the start page? section of XAMP's FAQ (quoting) :
The DocumentRoot folder is
"\xampp\htdocs". There is the
index site (index.php) the real
start page which is loaded after
executing of "http://localhost/".
So, I'd say, in your case, you'll have to work in C:\xampp\htdocs.
Still, of course, you can change that by modifying Apache's configuration and/or creating new VirtualHosts.