首页 > 解决方案 > 使用 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

有什么问题?

标签: .htaccessmod-rewriteurl-rewriting

解决方案


推荐阅读