【发布时间】:2020-05-17 18:34:34
【问题描述】:
我需要从我的网址中删除特定内容。这里我给一个页面名称user.php 并使用$_GET['url'] 获取它,然后使用PHP explode() 方法使其成为数组。
https://www.example.com/index.php?url=user
我需要像这样删除index.php?url=,
https://www.example.com/user
现在我已经在.htaccess 中使用了这段代码:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule index.php?url=$1 [QSA, L]
几乎一切都很好,user.php 页面加载完美。但是当我的 URL 出现斜线时,它会停止显示 CSS 或其他 IMG 目录。但是当我删除 .htaccess 文件时,它在这个 URL 中工作正常:
https://www.example.com/index.php?url=user/anonymous
但当我分配 .htaccess 规则时,此 URL 中不起作用。
https://www.example.com/user/anonymous
为什么我的所有样式表和其他目录都不能正常工作?
【问题讨论】:
-
斜杠将你的url变成一个目录,所以你需要使用
request_uri`example.com/index.php?url=user/anonymous
标签: php .htaccess mod-rewrite