如何在htaccess中删除部分网址

时间:2019-02-02 12:04:30

标签: 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

1 个答案:

答案 0 :(得分:-1)

用户RewriteRule规则
规则就像..

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

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