我已经改变了我的照片库,以我的网络托管帐户的子域。
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
发布评论