【问题标题】:redirect files folder path in drupal在drupal中重定向文件文件夹路径
【发布时间】:2013-12-12 07:35:15
【问题描述】:

我的 drupal 站点位于 example.com,为了在本地系统中进行配置,我创建了一个新文件夹 drupal 并将所有文件粘贴到该文件夹​​中。

当我在 /localhost/drupal 加载我的网站时,它的加载但图像没有加载,因为它指向内容中的 /localhost/sites/default/files/test.jpg...我不能去改变在所有内容中...

现在设置 .htaccess 将所有图像路径带到 /localhost/drupal/sites/default/files/test.jpg

<img alt="" src="/sites/default/files/finsoft-logo.png" style="width: 164px; height: 45px; ">

我试过这样,但它不是 wokring

RewriteRule ^/sites/default/files/(.*)$  /drupal/sites/default/files/$1 [L,NC]

以下是我在 .htaccess 文件中的代码

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

请帮我解决这个问题...

【问题讨论】:

    标签: .htaccess drupal


    【解决方案1】:

    从匹配模式中删除前导斜杠:

    RewriteRule ^sites/default/files/(.*)$ /drupal/sites/default/files/$1 [L,NC]
    
    • .htaccess 是每个目录指令,Apache 从 RewriteRule URI 模式中去除当前目录路径(因此是前导斜杠)。

    【讨论】:

    • 不,它不工作......我有这样的网址图像 ,这里的图片 url 没有重定向到 /drupal/sites/..
    • 您是否将此规则作为第一条规则放在您的 .htaccess 中?也可以试试:RewriteRule ^sites/default/files/(.*)$ /drupal/sites/default/files/$1 [L,NC,R]
    • 不,它不工作......我把这个重写规则放在“RewriteEngine On”行之后......
    【解决方案2】:

    您可能需要在 settings.php 文件中设置 $base_url 才能修复此问题。

    类似$base_url = 'http://localhost/drupal';

    虽然,修复 apache 配置文件以正确设置根目录可能会更容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-20
      • 1970-01-01
      • 2011-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多