Apache mod_rewrite redirects links to localhost. How to make .htaccess to work with each site in local machine?

1.3k Views Asked by At

I've installed Xampp as a web server and want to make clean URLs for one of my projects. So I put these simple lines in .htaccess file in the root of this project:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Also I made links in this project like this:

<a href="/about/">About Us</a>

I expected to go to localhost/this_project/about/, but it does not work. I go to localhost/about/ and this is wrong. How can I solve this problem?

I also have put this line in the 2nd line of .htaccess file, but no change happened.

RewriteBase /this_project/

Attention: There are many directories in htdocs folder for each project.

1

There are 1 best solutions below

0
On

You htaccess looks OK so I guess you are missing

AllowOverride All

In the VHOST <directory> block. If you server will fail after you add AllowOverride make sure you enabled mod_rewrite.