URL Rewrite keeps returning 404 Error

2019-07-20 07:21发布

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!

1条回答
倾城 Initia
2楼-- · 2019-07-20 08:05

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]
查看更多
登录 后发表回答