2013-12-12 119 views
0

我在我的drupal站點example.com並在我的本地系統中配置我創建了一個新的文件夾drupal並粘貼了該文件夾中的所有文件。在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; "> 

我想這樣的,但它不是玩具

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} 

請幫我解決這個問題的代碼...

回答

0

取下匹配模式的斜線:

RewriteRule ^sites/default/files/(.*)$ /drupal/sites/default/files/$1 [L,NC] 
  • .htaccess是每個目錄指令,Apache從RewriteRule URI模式中刪除當前目錄路徑(從而導致斜槓)。
+0

不,它不工作...我有像這樣的網址的圖像,這裏的圖像url不會重定向到/ drupal/sites/.. –

+0

您是否將此規則作爲第一條規則放入.htaccess中?也可以嘗試:'RewriteRule^sites/default/files /(.*)$/drupal/sites/default/files/$ 1 [L,NC,R]' – anubhava

+0

沒有它的不工作....我放置了這個重寫規則之後「RewriteEngine On」行... –

0

您可能需要在settings.php文件中設置$ base_url來解決這個問題。

喜歡的東西$base_url = 'http://localhost/drupal';

雖然,這可能是更容易解決您的Apache的配置文件設置正確的根目錄。