htaccess的子文件夹重定向

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

我最近搬到我的Word preSS网站的子文件夹。我想补充一个重定向在.htaccess文件中,以便于图像的链接,我最初上传到〜/可湿性粉剂内容/上传/将传递到〜/博客/可湿性粉剂内容/上传。 .htaccess文件必须保持的Word preSS的根文件夹正确读取它。这是我试过

I recently moved my WordPress website to a subfolder. I want to add a redirect in the .htaccess file so that the links to images I've uploaded originally to ~/wp-content/uploads/ will pass to ~/blog/wp-content/uploads. The .htaccess file must remain in the root folder for WordPress to read it properly. This is what I tried

Redirect /wp-content/uploads/ /blog/wp-content/uploads

这是伟大的工作,但我的主机其他领域的户口本,和所有其他领域的上传文件夹被重定向以类似的方式。

That worked great, except I host other domains on this account, and all of the other domain's upload folders were being redirected in a similar manner.

有没有办法来限制这种重定向到只有一个域?这样的 example/wp-content/uploads 的重定向到的 example/blog/wp-content/uploads 的,但是的 another/wp-content /上传的不?

Is there a way to restrict this redirect to just one domain? So that example/wp-content/uploads redirects to example/blog/wp-content/uploads, but another/wp-content/uploads does not?

谢谢大家!

推荐答案

假设你想要一个301重定向,采用这种RewriteEngine叙述的例子应该工作:

Assuming you want a 301 redirect, using this RewriteEngine example should work:

Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?example$ [NC] RewriteRule ^wp-content/uploads/(.*)$ www.example/blog/wp-content/uploads/$1 [R=301,L]

更多推荐

htaccess的子文件夹重定向

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

发布评论

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

>www.elefans.com

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