htaccess 重写返回 404 not found

编程入门 行业动态 更新时间:2024-10-26 10:31:02
本文介绍了htaccess 重写返回 404 not found的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I want it so that if the user types webaddress/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

本文发布于:2023-11-16 15:02:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605348.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!