Gerwin
Gerwin

Reputation: 1612

mod_rewrite doesn't work on localhost

I've tried to rewrite the URL of the website foto.php to Aquaria.php but for some reason it doesn't work, I'm not getting a console error or an error on the page.

I've placed the htaccess.htaccess file in the root directory of my Aquaria website.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
options +FollowSymLinks
RewriteRule foto.php(.*) Aquaria.php$1 [PT]
</IfModule>

I've used the following links to educate myself on how to use htaccess:

  1. URL Rewriting not working
  2. Rewrite URL with htaccess localhost
  3. Enable URL Rewriting
  4. htaccess tricks and tips

I've checked if there was a #before: LoadModule rewrite_module modules/mod_rewrite.so and it wasn't there, I then went on to try changing AllowOverride None to AllowOverride ALL as suggested by the third link, this didn't work either. After researching AllowOverride None I read that it shouldn't be used because it may grant access to all files for every user on the website.

Using phpinfo(); I checked if the Rewrite Module was loaded, which it was, I checked it where it says Loaded Modules, where I found mod_rewrite

TL;DR: The rewrite module doesn't give an error in the console on LocalHost, neither does it give an error on the page, I've used the links mentioned above to educate myself little by little to get to where I'am now.

Upvotes: 1

Views: 1976

Answers (1)

NooBskie
NooBskie

Reputation: 3841

Your file name must be .htaccess without a filename

To rename a .htaccess file without filename,

  1. Go to search
  2. Type in CMD
  3. Open your CMD
  4. Type in: rename pathnamehere\filename.htaccess .htaccess

Upvotes: 1

Related Questions