htaccess的子文件夹重定向 [英] .htaccess Subfolder Redirect
问题描述
我最近搬到我的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.com/wp-content/uploads 的重定向到的 example.com/blog/wp-content/uploads 的,但是的 another.com/wp-content /上传的不?
Is there a way to restrict this redirect to just one domain? So that example.com/wp-content/uploads redirects to example.com/blog/wp-content/uploads, but another.com/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.com$ [NC]
RewriteRule ^wp-content/uploads/(.*)$ http://www.example.com/blog/wp-content/uploads/$1 [R=301,L]
这篇关于htaccess的子文件夹重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!