用.htaccess替换URL的一部分 [英] Replace part of a URL with .htaccess

查看:95
本文介绍了用.htaccess替换URL的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不更改子页面的名称,现在的问题是Facebook,Twitter等上的所有共享链接都不再起作用。

I had to change the name of a subpage and now the problem is that all shared links on Facebook, Twitter, etc. are not working anymore.

这就是为什么我只尝试使用 .htaccess 重定向URL的一部分,但是我还没有解决方案。

That's why I am trying to redirect only a part of a URL with .htaccess but I have no solution yet.

它应该像这样工作:

www.mydomain.com/feeds/details/ --> www.mydomain.com/highlights/details/

希望您能帮助我!

推荐答案

这将取决于您的服务器,但是您正在寻找符合以下条件的东西

It will depend on your server but you are looking for something along these lines

    //Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com[nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]

//301 Redirect Entire Directory
RedirectMatch 301 /feeds(.*) /highlights/$1

这篇关于用.htaccess替换URL的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆