通过 mod 重写从 url 中删除查询字符串

发布于 2024-09-24 09:53:55 字数 188 浏览 0 评论 0原文

我对 mod 重写非常陌生,因此我们将不胜感激。

假设我有一个名为“www.sitename.com/index.php?p=contact”的网站 我需要删除“index.php?p=” 这样它看起来像“www.sitename/contact” 每次出现时,这意味着我应该能够截断“index.php?p=”,或者我应该能够用一些单词替换它。

I am very new to mod rewrite so any help would be apprecited.

let say i have a site named "www.sitename.com/index.php?p=contact"
and i need to remove "index.php?p="
so that it will look like "www.sitename/contact"
at its every occurence that means either i should be able to truncate "index.php?p=" or i should be able to replace it with some word.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇俏 2024-10-01 09:53:55
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?p=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?p=$1
沉睡月亮 2024-10-01 09:53:55

@zerkms
你的答案不起作用,它不完整

应该有

RewriteCond %{REQUEST_URI} ^/[^.]+$
RewriteRule (.*) index.php?p=$1

这些行匹配没有扩展名的URI,所以.php和.html文件
仍然可用

@zerkms
Your answer doesn't work, it's not complete

There should be

RewriteCond %{REQUEST_URI} ^/[^.]+$
RewriteRule (.*) index.php?p=$1

These lines matches URI with no extension, so .php and .html files
will still be available

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文