2014-02-14 37 views
0

我在技術上有兩個子目錄。 /產品/行業/htaccess 301重定向子目錄但不包含子目錄內的任何東西

我想重定向如下:

/products/industry to /products/#industry 

但是我不希望重定向這樣的:

/products/industry/product-name 

或可能遵循什麼/行業。這是我在我的htaccess中無法使用的。也許我很接近?

RewriteEngine On 
RewriteCond %{REQUEST_URI} ^/products/industry[/]?$ 
RewriteRule (.*) /products/#industry [R=301,L] 

回答

0

你可以這樣做:

RewriteEngine On 
RewriteBase /bti/ 

RewriteRule ^(products)/(industry)$ $1/#$2 [R=301,L,NE,NC] 
+0

嗯,似乎並沒有爲我工作。 –

+0

在我的測試中,將'/ products/industry'重定向到'/ products /#industry'您能否確保將此規則作爲第一條規則並在新瀏覽器中嘗試使用。 – anubhava

+0

我修改它以使用子目錄。我仍然沒有在多個瀏覽器中獲得結果並清除緩存。 RewriteRule ^(bti)/(products)/(industry)$ /​​ $ 1/$ 2 /#$ 3 [R = 301,L,NE,NC] –