htaccess 重写返回 404 not found [英] htaccess rewrite returns 404 not found

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

问题描述

我想要这样,如果用户输入webaddress.com/artist/P1/P2/,它会使用/artist/index.php?artist=P1&am=P2

I want it so that if the user types webaddress.com/artist/P1/P2/ it will make it use /artist/index.php?artist=P1&am=P2

P1 将是艺术家姓名,因此它可以包含字母和数字.P2 将是一个数字,所以只是数字.

P1 would be an artist name, so it could contain both letters and numbers. P2 would be a number, so just numbers.

我想要它,以便 P1 是必不可少的,而 P2 不是,因为现在它只返回在该地址上找不到的 404.当前代码:

I want it so that P1 would be esssential, whereas P2 isn't because right now it just returns 404 not found on that address. Current code:

RewriteEngine on
RewriteRule ^artist/([^/]+)/(\d+)/$ /artist/index.php?artist=$1&am=$2 [L]

推荐答案

/artist/index.php 暗示服务器上有一个根目录调用/artist/.我以某种方式怀疑这一点(它确实存在,但不应该).

/artist/index.php implies there is a root directory on the server call /artist/. I somehow doubt this (and it it does exist, it shouldnt).

删除艺术家之前的前导/,看看是否有效.

Remove the leading / before artist, and see if that works.

RewriteEngine on
RewriteRule ^artist/([^/]+)/(\d+)/$ artist/index.php?artist=$1&am=$2 [L]

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

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