1

我的网页上有此链接格式:

https://mypage.com/index2.php?page=registration
https://mypage.com/index2.php?page=food&category=1

第一种类型被替换为:

https://mypage.com/registration (works well)

我想将第二个格式化为:

https://mypage.com/food/1 (doesn't work, the page is loaded, but the images don't)

所以我创建了以下 htaccess 文件:

RewriteEngine on
RewriteRule ^$ index.php [L]
RewriteRule ^([^/.]+)?$ index2.php?page=$1 [L]
RewriteRule ^food/([^/.]+)?$ index2.php?page=food&category=$1 [L]

但不起作用。:(这有什么问题?图片在哪里?谢谢你的回答。

4

1 回答 1

0

(不起作用,页面已加载,但图像没有)

可能是因为您的链接是相对的(不以 a 开头/),并且当您在 之后有多余的斜杠时/food,它会更改 URL 库(尝试访问不存在的/food/目录中的图像)。将所有链接更改为绝对 URL 或在页眉中添加基础:

<base href="/" />
于 2013-12-05T00:02:11.593 回答