martoio
martoio

Reputation: 23

URL Rewrite keeps returning 404 Error

I've created a .htaccess file for the URL rewrite, and I tested it using http://htaccess.madewithlove.be/ and it says the URL rewrite is correct, but when testing the page keeps giving me a 404 error.

Here is the .htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^article/(.*)$ /article/index.php?id=$1 

The URL rewrite I need is the following:

http://www.mydomain.com/article/test  // To redirect to: 
http://www.mydomain.com/article/index.php?k=test

Can anyone tell me what I am messing up? Thank You!

Upvotes: 2

Views: 1113

Answers (1)

jerdiggity
jerdiggity

Reputation: 3665

First, make sure a file exists named /article/index.php and then give this a try:

RewriteEngine On
RewriteBase /
# Condition: the requested file is non-existent
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^article/(.*)$ /article/index.php?id=$1 [L,R=301]

Upvotes: 1

Related Questions