Search code examples
php.htaccessxampp

.htaccess RewriteMod not working correctly in XAMPP


I just setup an .htaccess file for make prubes in localhost with XAMPP "3.2.4". This .htaccess setup works fine on my website, but is not working on localhost.

httpd.conf:

LoadModule rewrite_module modules/mod_rewrite.so
# Is activated

All "AllowOverride" is set to All

.htaccess:

Options -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME}\.css -f
RewriteRule ^(.*)$ $1.css
RewriteCond %{REQUEST_FILENAME}\.js -f
RewriteRule ^(.*)$ $1.js

RewriteCond %{REQUEST_FILENAME}\.jpg -f
RewriteRule ^(.*)$ $1.jpg
RewriteCond %{REQUEST_FILENAME}\.png -f
RewriteRule ^(.*)$ $1.png
RewriteCond %{REQUEST_FILENAME}\.gif -f
RewriteRule ^(.*)$ $1.gif

RewriteRule ^item/([\w-]+)/?$ product.php?id=$1 [L,QSA,NC]
RewriteRule ^error/([\d-]+)/?$ error.php?code=$1 [L,QSA,NC]

RewriteRule ^sitemap.xml sitemap.php [QSA,L,NC]

ErrorDocument 400 http://localhost/shop/error/400
ErrorDocument 401 http://localhost/shop/error/401
ErrorDocument 403 http://localhost/shop/error/403
ErrorDocument 404 http://localhost/shop/error/404
ErrorDocument 410 http://localhost/shop/error/410
ErrorDocument 500 http://localhost/shop/error/500

I think everythink is setup ok, but I don't know why is not working in local

My .htaccess is in the root of the project and if I write something like "sdlkfjlkdsjflksdjf" it show me 500 Internal Error, so that means that .htaccess is readed.


Solution

  • Ok, sorry, forget it, the problem was on RewriteBase location