Apache 修改以生成一个简短的URL

Apache 修改以生成一个简短的URL,apache,wordpress,mod-rewrite,short-url,Apache,Wordpress,Mod Rewrite,Short Url,我有一个类似的url: 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

我有一个类似的url:

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

删除类别库很容易,不需要对.htaccess进行更改。该插件不会永久更改数据库中的URL,因此,如果禁用该插件,您将恢复您的类别库,而不会有404帖子。

这是一个Wordpress博客,我相信这是通过重写完成的。上面的URL是我希望此规则生效的唯一情况。我不想在“任何东西”前面加上category。我只想用一个更短的URL替换完整的URL。我明白了,我已经修改了这个特定情况下的重写规则。