【问题标题】:htaccess redirect from folder with subdirectory to single path directoyhtaccess 从带有子目录的文件夹重定向到单个路径目录
【发布时间】:2019-01-07 11:39:49
【问题描述】:

以前我的网站是wordpress,现在转换成html。

我有 500 多个 pdf 需要从

重定向

mysite.com/wp-content/themes/my-theme/pdfs 文件夹到mysite.com/pdf/

【问题讨论】:

  • 我得到了答案,RewriteRule ^wp-content/themes/my-theme/pdfs/(.*)$ /pdf/$1 [R=301,NC,L]

标签: .htaccess mod-rewrite


【解决方案1】:

您是否具有对该站点的服务器级访问权限?如果是这样,我会在您网站的公共根目录中将create a symbolic link 发送到wp-content/themes/my-theme/pdfs 并将其命名为pdf

如果你能做的只是.htaccess,那么你可以像这样创建一个文件:

Options +FollowSymLinks
RewriteEngine On 
RewriteRule ^pdf/(.*)$ /wp-content/themes/my-theme/pdfs /$1 [R=301,NC,L]

您可以查看a great tutorial 的重写规则。

【讨论】:

    【解决方案2】:

    我试过这样它对我有用。

    重写规则 ^wp-content/themes/my-theme/pdfs/(.*)$ /pdf/$1 [R=301,NC,L]

    【讨论】:

      猜你喜欢
      • 2014-11-26
      • 2017-07-27
      • 2017-01-29
      • 2021-09-03
      • 2011-01-19
      • 1970-01-01
      • 2016-07-18
      • 2012-02-27
      相关资源
      最近更新 更多