Apache AllowOverride directive - php

There's a server for which I don't have access to the control panel; I can only access a directory by FTP.
I need to know if the Apache AllowOverride directive is enabled in that directory.
I want to check that Apache has mod rewrite enabled and that the options allow Override All.
How do I do it with a PHP script?
Thanks

I don't think there's any way to do that in PHP. The only way is to put some commands into .htaccess that depend on AllowOverride and mod_rewrite, and see if you get 500 Internal Server Error when you visit the directory by web. For example, you can put
Options all
to test AllowOverride Options,
Allow from all
to test AllowOverride Limit, or
RewriteRule .* -
(which does nothing) to test mod_rewrite.

Related

Laravel: no joy after MAMP upgrade from 3.4 to 4.1

As I am suffering a weird redirect problem and I read MAMP could be the cause I decided to upgrade it.
I have my virtual hosts set and they are enabled in the conf.
I set correct ports and set PHP version to 5.6.31 (it was 5.6.10).
What happens when I start the servers is I can open the welcome screen of the laravel project (project.dev) but then the routes don't work with error 404. Example project.dev/home or project.dev/login etc.
Any clue?
--- edit
I added this to my vhost and now it's working. Not sure if all the stuff there is needed as I just copied from the web. Strangely I didn't have anything of this in the past and it worked. Could it be apache was configured to allow mod_rewrite or something?
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
In your httpd.conf file set AllowOverride directive from None to All, for example:
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
The default in Apache 2.3.9 and later is None, previous versions is was All. From the online docs:
When this directive 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.
When this directive is set to All, then any directive which has the
.htaccess Context is allowed in .htaccess files.

Setting directives in Vagrant (and ProcessWire)

I'm having a problem where it seems like my Vagrant VirtualBox isn't reading the .htaccess file for a site I have mapped out. (a proccesswire site)
I've don't know enough about Vagrant to find where I should be editing the directives so that my .htaccess file will be read. As far as I've gathered from searching I need to set a directive like so:
<Directory /var/www>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
It seems the primary offender is the AllowOverride is typically set to "None" and needs to be "All". But I have put this in a httpd.conf file in apache and I'm guessing that isn't correct.
A bit more information: When I installed PW in the site root I got this error: " Unable to determine if Apache mod_rewrite (required by ProcessWire) is installed. ". As a result when I try to access a part of the CMS, that is usually handled by rewrite rules, the url (/admin or /processwire by default) just reroutes me to the homepage.
Also, I can delete everything in .htacess or add garbage to it and no errors occur. This tells me that .htacess isn't even being read.
I appreciate the help.

How to set Apache to accept override from .htaccess

I have tried to run php in .html file and failed despite trying all solution suggested here. Someone suggested it maybe because Apache is not setup to accept .htaccess overrides. Maybe that is the reason. Now the question is how do I setup Apache?
To be able to use .htaccess files, the directive AllowOverride must be set for the directory into which you want to put .htaccess files. E.g.:
<Directory "/usr/local/httpd/htdocs">
AllowOverride All
</Directory>
This must be set in the core httpd.conf file of Apache. If you're on a shared host, you likely have no access to that (and that's correct, for security reasons).

apache url rewrite connection reset on root directory

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

my zend framework application is not reading htaccess file even after enabling url rewrite in apache

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

Categories