I have set up a server on my Mac (OSX 10.9) but it's returning a 500 error with the following message in the error log…
[alert] [client ::1] /Users/user/Sites/mysite/.htaccess: AllowOverride not allowed here
Here's the code in my .htaccess file
Options +FollowSymLinks -MultiViews
AllowOverride All
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteMap lc int:toLower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^i/(.*)/(.*)-(.*)$ /items/?id=$1&range=$2&type=$3 [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^c/(.*)$ /category/?menu=$1 [L,QSA,NC]
And here's the relevant httpd.conf code (let me know if there's anything else that would help)
DocumentRoot "/Users/user/Sites/mysite"
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
<Directory "/Users/user/Sites/mysite">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Any ideas?
AllowOverride All doesn't belong in the htaccess file. It's used in the server config (httpd.conf) to set what an server config parameters an htaccess file can override. So obviously, it would be wrong to be able to configure what parameters htaccess files can override from within htaccess files.
Remove it from your htaccess file. You've already defined AllowOverride All in your httpd.conf in the right places.
AllowOverride controls .htaccess security and behaviour and cannot be set inside of .htaccess itself.
Remove AllowOverride All from the .htaccess file, that's all.
Take AllowOverride All out of your .htaccess file.
Related
When I try to rewritte my URL, and access to test page ( test.php ) , in the url the real path is add, so, I have a 404 error.
http://mywebsite.fr/home/web/dev/test/ <- /home/web/ is the real path
and it can't add to the URL.
In my configuration, I have writting this :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName *
ServerAlias *
DocumentRoot /home/web
<Directory />
Options FollowSymLinks
AllowOverride None
DirectoryIndex index.php
</Directory>
<Directory /home/web/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
DirectoryIndex index.php
</Directory>
In my htaccess :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]
If you want to add extensions to your URLs like .php or .html then remove those shown rules from .htaccess and add this line:
Options +MultiViews
Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
On Live server, to resolve 404 error when trying to access any page, changed below setting in httpd.conf
<Directory "/usr/local/apache/htdocs">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
But on next day it gets reset to below
<Directory "/usr/local/apache/htdocs">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Really hoping that it was going to work, but no go. This is what .htaccess looked like after I changed the permalink option:
<Directory />
Options +FollowSymLinks
AllowOverride All
</Directory>
<Files .htaccess>
order allow,deny
deny from all
</Files>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The pages are still not accessible. Changing AllowOverride None to AllowOverride All works, but it resets again to default setting somehow.
404 page not found error appears often even after changing httpd.conf and .htaccess.
Note: mod_rewrite is already installed
I have a broken Cake PHP site that I did not write, but am charged with fixing. I have the main controller up, however no css/js/images, and when I click a link I get a 404 not found. I believe something is incorrect with mod_rewrite or the docroot config in apache.
While reading through Cake documentation, I came across this:
"app/webroot
In a production setup, this folder should serve as the document root for your application. Folders here also serve as holding places for CSS stylesheets, images, and JavaScript files."
In my /etc/apache2/sites-enabled/this-site, I see this:
DocumentRoot /u02/data/docroots/this_site
<Directory /u02/data/docroots/this_site>
Options -Indexes
AllowOverride none
Order deny,allow
Allow from all
</Directory>
So, my question:
does the above config block need to have:
/u02/data/docroots/this_site/app/webroot as the DocumentRoot and ?
Anywhere else you can think to look for troubleshooting this?
Since you have access to edit the apache config files - it's most appropriate to make a standard production install.
Fixing the docroot
does the above config block need to have: .../app/webroot as the DocumentRoot
Assuming that path exists: yes.
This will fix the broken css/js/images.
Fixing mod rewrite
Put the rewrite rules in the virtual host config:
DocumentRoot /u02/data/docroots/this_site/app/webroot
<Directory /u02/data/docroots/this_site/app/webroot>
Options -Indexes
AllowOverride none
Order deny,allow
Allow from all
// added
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
This will then route requests for anything that's not a file to the application.
Verify that the rewrite rule used is compatible with the version of CakePHP in use, the above is based on the rule for the latest release - it changed over the years and using the wrong rewrite rule may have unexpected side effects.
What's actually broken
AllowOverride none
This prevents the .htaccess files from being read by apache. If you were to change this to AllowOverride all, and assuming the currently-ignored .htaccess files exist, the site would work - but as a development install.
Try this:
<VirtualHost *:80>
ServerAdmin xxxxxx#test.ro
ServerName test.ro
ServerAlias www.test.ro
DirectoryIndex index.php
DocumentRoot /u02/data/docroots/this_site
ErrorLog /u02/data/docroots/this_site/error.log
CustomLog /u02/data/docroots/this_site/access.log combined
<Directory "/u02/data/docroots/this_site">
Options -Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And you should have 3 .htaccess files:
/u02/data/docroots/this_site/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
/u02/data/docroots/this_site/app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/u02/data/docroots/this_site/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Hope this helps ;)
I'm working on a symfony 1.4 project which is working, i wanted to work on a local copy on my personal machine; so I've settled a virtual host (I'm on a Windows 8.1 with xamppp web server).
I'm getting a 500 error when trying to access from browser by giving "joyaa" (it's the virtualhost alias), and in some of my test I had a redirect to the project working on the server (it's a statement in .htaccess)
This is the virtual host defining:
<VirtualHost *:80>
ServerName joyaa
DocumentRoot "C:/xampp/htdocs/yaol/web"
DirectoryIndex index.php
<Directory "C:/xampp/htdocs/yaol/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf C:/xampp/htdocs/yaol/lib/vendor/symfony/data/web/sf
<Directory "C:/xampp/htdocs/yaol/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
Alias /joyaa "C:/xampp/htdocs/yaol/web"
<Directory "C:/xampp/htdocs/yaol/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and this is the .htaccess defining:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /joyaa
RewriteRule ^yaol(.*)$ http://www.arcadja.com/joyaa$1 [L,R=301]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Probably it's a configuration problem but I'm not sure about where to look at... Please help. Thanks
I'm trying to debug a php site and I've got a routing problem that I can't figure out.
It's a custom built site and most of the requests are routed via index.php
The problem I am having is that on the live server (Linux / Apache):
http://www.sitename.com/cart is routed through index.php as it should be.
but on my test server (osx / apache):
http://www.sitename.com/cart goes straight to http://www.sitename.com/cart.php without being routed through index.php
I assume it's something to do with the .htaccess file (below) but I can't figure out what. Also the .htaccess file is the same on both servers so I don't understand why it's working differently, any help much appreciated.
AddType application/x-httpd-php .html
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^robots.txt$ robots_ssl.txt
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule ^([^.]+)\.s?html$ /index.php?q=$1 [L,QSA]
RewriteRule ^([^.]+)\.s?htm$ /index.php?q=$1 [L,QSA]
RewriteRule ^([^.]+)\.s?xml$ /index.php?q=$1 [L,QSA]
RewriteRule ^([^.]+)\.s?asp$ /index.php?q=$1 [L,QSA]
RewriteRule ^([^.]+)\.s?aspx$ /index.php?q=$1 [L,QSA]
RewriteRule ^robots.txt$ /index.php?q=$1 [L,QSA]
RewriteRule ^([^.]+)$ /index.php?q=$1 [L,QSA]
RewriteRule ^admin/.*$ - [PT]
#php_flag display_errors off
php_value default_charset ISO-8859-1
php_flag magic_quotes_gpc on
php_flag magic_quotes_runtime off
The virtual host file is as follows:
<VirtualHost *:80>
DocumentRoot "/Users/jim/Sites/sitename.com/public_html"
ServerName sitename.com
ServerAlias www.sitename.com
<directory "/Users/jim/Sites/sitename.com/public_html/">
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
</directory>
</VirtualHost>
This is happening because of this line in your vhost config:
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
Not sure why you need Multiviews to be set to "on" but it's part of mod_negotiation and processes the request before mod_rewrite does. It takes requests like /cart and decides whether there's a fuzzy match against an existing resource. It sees /cart.php and assumes that's what you want and serves up the request before mod_rewrite even gets a chance to do anything. You can turn it off by adding a - in front:
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI -MultiViews
You can also do this via the htaccess file's Options directive:
Options +FollowSymLinks -MultiViews