Xriuk
Xriuk

Reputation: 392

.htaccess RewriteEngine not working

I have this .htaccess:

RewriteEngine On
RewriteRule ^/test$ /home.php

So mysite.com/home.php and mysite.com/test are supposed to be the same now?
But when I go to mysite.com/test I get a 404 error.

Any help?

Upvotes: 3

Views: 1305

Answers (1)

anubhava
anubhava

Reputation: 784958

That is because of leading slash in your rule.

Change that to:

RewriteEngine On
RewriteRule ^test/?$ /home.php [L,NC]

.htaccess is per directory config hence Apache doesn't match leading / while matching a URI `/test1

Reference: Apache mod_rewrite Introduction

Upvotes: 1

Related Questions