2012-10-27 31 views
0

是否有任何規則可以寫入,以使對我的圖像文件夾的所有請求都指向一個文件夾。我正處理很多鏈接,所以我不想把../通過htaccess指向更高文件夾的圖像請求

例如:http://hostingxtreme.com/ajax/images/logo.png

應該成爲http://hostingxtreme.com/images/logo.png

感謝

這裏我使用 Dosent的代碼似乎工作!
php_value register_long_arrays On
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine On
RewriteRule ^/?ajax/images/logo.png$ /images/logo.png [L,R=301]
</IfModule>

回答

1

在htaccess文件在你的文檔根目錄,添加或者:

Redirect 301 /ajax/images/logo.png /images/logo.png 

或者,如果你需要使用mod_rewrite:

RewriteEngine On 
RewriteRule ^/?ajax/images/logo.png$ /images/logo.png [L,R=301] 
+0

Dosent似乎工作! Ive更新了我的帖子 – RohanJM

+0

@RohanJM規則需要在您的路由規則之前*。路由規則捕獲所有內容並將它們指向'/ index.php',因此重定向永遠不會發生。你需要在'RewriteBase /'行下面添加它。 –

+0

謝謝,它可以不用把logo.png工作嗎?所以基本上把ajax/images映射到/ images – RohanJM

0

我知道了!

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} (ajax/|ajax/.*/)images/(.*) 
RewriteRule (ajax/|ajax/.*/)images/(.*) images/$2 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} (ajax/|ajax/.*/)stylesheets/(.*) 
RewriteRule (ajax/|ajax/.*/)stylesheets/(.*) stylesheets/$2 
相關問題