regex - 使用 htaccess 从 url 中删除查询字符串
问题描述
我需要一些有关 htaccess 的帮助。你会好心帮忙吗?我有这样的网址
https://example.com/index.php?p=application-intelligence
[或者]
https://example.com/?p=application-intelligence
基本上 index.php 被传递了一些参数'home' 以知道要加载哪个页面,即 home.php 所以我试图在你的博客上关注你的帖子,但运气不佳。
所以我希望最终的代码是
https://example.com/application-intelligence
这是我的代码。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?p=$1
也适用于 https://example.com?p=home
我希望它只是
解决方案
这就是我的 apache 虚拟主机 conf 文件中的内容:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
推荐阅读
- ruby-on-rails - 没有路由匹配 {:action=>"show", :controller=>"profiles", :user_id=>nil},缺少必需的键:[:user_id]
- c# - 在 uwp 中将一个网格的内容复制/克隆到另一个网格
- c - C中带有2个以上参数的大小写可变参数宏
- python - 为什么 Python 3 反序列化 json 文件的速度如此之快?
- c++ - 从 C++ 调用汇编程序函数,链接错误
- php - 正则表达式获取文件名中的维度
- node.js - 在学校项目“分布式计算”中计算什么?(有用)
- php - 数组foreach形成显示并得到相同的结果
- bash - 计算多个子目录中每个文件的行数
- excel - VBA:将数据从源工作簿复制并粘贴到目标工作表如果它们的单元格“A1”值彼此相等