URL重写不断返回404错误 [英] URL Rewrite keeps returning 404 Error

查看:169
本文介绍了URL重写不断返回404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为URL重写创建了一个.htaccess文件,并使用 http://htaccess.madewithlove .be/,它表示URL重写是正确的,但是在测试页面时,始终显示404错误.

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.

这是.htaccess:

Here is the .htaccess:

RewriteEngine On
RewriteBase /

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

我需要的URL重写如下:

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!

推荐答案

首先,确保存在名为/article/index.php的文件,然后尝试一下:

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]

这篇关于URL重写不断返回404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆