gpt4 book ai didi

php - 使用 php 和 .htaccess 进行友好的 url 重写。相对链接到 css 图像和 js 的困难

转载 作者:行者123 更新时间:2023-11-27 22:33:03 25 4
gpt4 key购买 nike

我目前有一个这样的网址:play.php?place=idplace&event=idevent

我以这种方式启用了友好的 url:

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ play.php?place=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ /play.php?place=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ /play.php?place=$1&event=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ /play.php?place=$1&event=$2

只有一个参数(那里的地点 ID),一切正常。但是当出现像 mysite/theplace/theevent 这样的两个参数(地点和事件)时,我所有的亲戚链接(css、js 和 imgs)都不起作用,我的页面似乎认为它实际上在 theplace/文件夹中,而不是在根/一个。

关于这个问题的想法?

非常感谢

纪尧姆

最佳答案

您必须使用至少来自域的绝对路径,即

/images/myimage.png

您也许可以用另一种方式解决这个问题,但随着您的 URL 重写变得更高级,它只会变得更烦人。

关于php - 使用 php 和 .htaccess 进行友好的 url 重写。相对链接到 css 图像和 js 的困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3353513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com