2011-01-20 186 views
2

我有幾個URL像htaccess的重定向而不更改URL

http://www.mydomain.com/statecode1-folder1

我想它重定向到/文件夾1 /頁,但我想顯示的原始網址如上在瀏覽器地址欄中。

請注意,我沒有文件夾statecode1-文件夾1和statecode2,文件夾1

目前我使用下面的.htaccess被重定向,但它改變了地址欄

#Options +FollowSymlinks 
RewriteEngine On 
RewriteBase /
RewriteCond %{REQUEST_URI} ^/ statecode1-folder1 $ 
RewriteRule ^(.+)/folder1 [L] 
RewriteCond %{REQUEST_URI} ^/ statecode2-folder1 $ 
RewriteRule ^(.+)/folder1 [L] 
+0

你不能這樣做.htaccess – Tobias 2011-01-20 07:34:53

回答

2

你不應該斜線後的空格!而結局$也許這是問題?通常,本地重定向應該可以工作。嘗試是這樣的:

RewriteEngine On 
RewriteBase /
RewriteCond %{REQUEST_URI} ^/statecode1-folder1 
RewriteRule ^.* /folder1 [L] 
RewriteCond %{REQUEST_URI} ^/statecode2-folder1 
RewriteRule ^.* /folder1 [L] 
0

的答案與此類似,至少你可以嘗試一下:

RewriteCond %{HTTP_HOST} ^Domain.com/statecode1-folder1 $ 
    RewriteRule ^(.*) Domain.com/newpath [P] 

的多個URL使用$ 1個符號,以確保超過一(幾)URL(S )與不同的URI。