2011-01-20 182 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。