301重定向不工作的htaccess

编程入门 行业动态 更新时间:2024-10-14 12:22:00
本文介绍了301重定向不工作的htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经改变了我的照片库,以我的网络托管帐户的子域。

I have changed my photo gallery to a subdomain of my web hosting account.

由于谷歌仍然引用旧链接到我的照片,我希望做一个301重定向与htaccess的。在301重定向我认为最好的方法是 搜索传入的URL在旧的链接特定的字符串,如果找到则只是附加的照片作为子域链接。

Since google is still referencing the old links to my pictures, I want to do a 301 redirect with htaccess. In the 301 redirect I think the best way is to search incoming URL for specific string in old link and if found then just append photos to link as subdomain.

例如, 进入URL - www.MYDOMAIN/photography-...y/12345_crABCD

eg incoming URL - www.MYDOMAIN/photography-...y/12345_crABCD

检查收到的URL字符串摄影图库 如果找到则301重写URL通过添加子域名照片网址

check incoming URL's for string "photography-gallery" if found then 301 rewrite URL by appending subdomain photos to URL

photos.MYDOMAIN/photography-gallery/12345_crABCD

我也试过这个redirectin htaccess的只是去到我的域名,如果字符串中找到,它没有做任何事情。

I also tried this redirectin htaccess to just go to my domain if string found and it did not do anything

redirect 301 /photography-gallery/ www.MYDOMAIN/

有人可以帮助撰写前pression此htaccess的重定向或重写?谢谢

Can someone help with writing the expression for this htaccess redirect or rewrite? Thanks

推荐答案

如果你想在同一个URL重定向到另一个域名,你可以使用这个简单的 重写规则

If you want to redirect the same URL to another domain, you can use this simple RewriteRule

RewriteEngine on RewriteRule ^photography-gallery/.*$ photos.mydomain/$0 [R,L]

当一切都按你期望的那样,你可以修改研究到 R = 301 。

When everything works as you expect, you can change R to R=301.

切勿 301 测试启用,看到这个答案提示调试的.htaccess重写规则了解详细信息。

Never test with 301 enabled, see this answer Tips for debugging .htaccess rewrite rules for details.

更多推荐

301重定向不工作的htaccess

本文发布于:2023-10-31 13:45:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546263.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   工作   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!