2011-04-06 112 views
0

重定向如何使從 site.com/ 重定向る/blablabla到 site.com/blablabla ?.htaccess。與重寫條件

還有一如果鏈接site.com/en/blablabla服務器返回404, 那麼我需要重定向到site.com/blablabla

我的.htaccess:

########## Begin - Joomla! core SEF Section 
# 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/index.php 
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC] 
RewriteRule (.*) index.php 
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] 
# 
########## End - Joomla! core SEF Section 

######### MY RULES ######### 
RewriteCond %{REQUEST_URI} \/ru\/(.*) 
RewriteRule (.*)$ /%1 
+0

是否特定於「** ru **」或任何單詞? 「en」也是一樣...... – 2011-04-06 15:52:00

+0

在我的情況下,「ru」是特定的。 – 2011-04-06 16:07:53

回答

0

你能去除下######### MY RULES ######### 行中的所有行,並把這個行:

RewriteRule ^(en|ru)/(.*)$ /$2 [R,L] 

這將處理/ ru/foo和/ en/foo URL。

0

首先, : 在.htaccess文件的頂部添加RewriteEngine on


試試這個規則:對於RU

ErrorDocument 404 /error404.php 

RewriteCond %{REQUEST_URI} \/ru\/(.*) 
RewriteRule (.*)$ /%1 
在這種情況下(英文版)

我可以建議你檢查的ErrorDocument HTTP_REFERER(在上述情況下,其error404.php)...和請求重定向到相應的網頁... (在你的情況下,其/ blablabla)

希望你有我的觀點.. :)

+0

我的網站是多語言。現在http://f1u.org/ - 俄語,http://f1u.org/en - english。昨天的俄文版本位於http://f1u.org/ru。因此,我想將所有網址http://f1u.org/ru/*重定向到http://f1u.org/* – 2011-04-06 16:37:29

+0

另一個問題:Google索引此頁面:http://f1u.org/en/its-interesting/166-cricri,但它不再存在。如果服務器返回404,我想要重定向到同一個俄羅斯頁面http://f1u.org/its-interesting/166-cricri。所以我需要一些規則,將所有404英文鏈接重定向到俄語。 – 2011-04-06 16:38:55

+0

嘗試了RU的規則。不行。 :( – 2011-04-06 16:42:20