php - 如何删除htaccess中的部分url

标签 php linux .htaccess

我只想使用 .htaccess 在我的博客中保留 URL 的最后一部分。

https://example.com/blog/category1/category2/postname1
https://example.com/blog/category1/postname2

我只想拥有:

https://example.com/blog/postname1
https://example.com/blog/postname2

最佳答案

用户RewriteRule规则
规则就像......

RewriteRule ^([a-zA-Z0-9-]+)$  blog/postname1?slug=$1 [L]

检查此网址:- How to rewrite url with post title slug?

关于php - 如何删除htaccess中的部分url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54492911/

相关文章:

php - 在搜索结果中显示 2 列中 1 个表的信息。 (PHP-拉拉维尔)

php - 如何使用 PHP 获取服务器的本地 IP 地址?

linux - 为什么在 Docker 中运行 "not a tty"时得到 "tty"?

html - Windows 7 上的 Internet Explorer 10 不加载嵌入字体

.htaccess - 使用 cloudflare SSL 时如何不重定向 Twitterbot?

php - 是否可以有两个 Predis 连接到同一 Redis 实例的不同数据库?

php - mysqli_connect()上的PHP fatal error ;

linux - Oracle Linux,在 macOS 上的 VirtualBox 中运行时防止网络适配器休眠

c# - 无法在 CentOS amd64 上执行二进制文件

php - redirect_status 的奇数 (44)