URL Rewrite keeps returning 404 Error

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 03:53:24

问题


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:


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]


来源:https://stackoverflow.com/questions/24445502/url-rewrite-keeps-returning-404-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!