我最近搬到我的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的子文件夹重定向
发布评论