apache - mod_rewrite 制作短网址

我有一个类似的网址:

http://skepticalgamer.com/category/slam-the-controller

我想从 URL 中去掉“类别”。所以我想要:

http://skepticalgamer.com/slam-the-controller

就像上面的原始 URL 一样。用 mod_rewrite 可以做到吗?

最佳答案

是的,您可以使用 mod_rewrite 执行以下操作:

RewriteRule ^slam-the-controller$ category/slam-the-controller

这将采用 URL:

http://skepticalgamer.com/slam-the-controller

并将其重写为:

http://skepticalgamer.com/category/slam-the-controller

https://stackoverflow.com/questions/3055794/

相关文章:

url - 是否有用于将短网址翻译回常规链接的 API?

url - 短网址冲突。更喜欢项目还是项目列表?

url - 谷歌短网址如何运作?

javascript - 使用 JSON 使用 Javascript 缩短 URL

php - 修改 url 更短的脚本

php - 如何使用短 URL 将用户重定向到自定义表单?

php - 如何用 PHP 中的 goo.gl 等短 URL 识别域名?

mongodb - 在分布式数据存储中生成短 URL

apache - 无法让 mod_rewrite 正确(且不可见地)重写我的 URL?

regex - 解析短网址的正则表达式