.htaccess - 使用 htaccess 将 url 重写为一级链接
问题描述
我想要实现的是:
website/index.php?post=my-post-name
成为:
website/my-post-name
我想使用$_GET['post']获取帖子名称。
我的.htaccess以我需要的方式重写了 url,但我无法使用 $_GET 检索帖子名称。它是空的。
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/* index.php?post=$1
有什么问题?
解决方案
推荐阅读
- bash - 集群上 bash 运行之间的延迟
- amazon-web-services - 是否可以按类型(即标准、标准 IA、减少冗余)列出 s3 存储桶?
- python - 我想创建一个工具栏,在单击按钮时更改框架
- node.js - 如何使用量角器选择与文本匹配的行
- wikipedia-api - 从 wikipedia API 获取 wikitext?
- c# - 从 user32.dll EnumDisplayDevices 取回坏字符串
- node.js - Node.js %OptimizeFunctionOnNextCall - 运行时函数错误
- javascript - JSScript 不会在 Xsplit 上加载
- javascript - 从窗口对象读取属性是否昂贵?
- c# - 我想创建一个类似 Minecraft 村民的 AI