Klaus Breyer
Klaus Breyer

Reputation: 387

Failing with a simple htaccess redirect

I wanted to do a simple .htaccess redirect, but I can not make it work.

RewriteEngine On
Redirect about.html article.php?id=about [L]

The script and .htaccess is living in a subdirectory: domain.tld/directory/

Where is my error?

Upvotes: 0

Views: 20

Answers (1)

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

You are mixing the rules of mod_alias and mod_rewrite,

If you want only redirect with mod_rewrite use below in directory/,

RewriteEngine On
RewriteRule ^about.html$ article.php?id=about [R=301]

And if you want to rewrite, assuming about.html is not exists.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^about.html$ article.php?id=about [L]

Upvotes: 1

Related Questions