2016-12-16 109 views
2

我有2個網站。說它5p_fronthttp://localhost/5p_front/)和5p_grouphttp://localhost/5p_group/)(在OctoberCMS開發)(在開發CakePHP的htaccess無法正常工作,有更多斜線的子網址

5p_front我有一個的.htaccess文件和我爲這一個條件將重定向到5p_group網站,只要它發現一個單詞有5p_group_login在網址中。這裏是低於

的.htaccess

RewriteRule ^5p_group_login.*$ http://localhost/5p_group [L,R=301] 

代碼所以,如果有人試圖去這裏例如http://localhost/5p_front/5p_group_login,他們會簡單地被重定向到這裏http://localhost/5p_group/

從主頁和其他頁面例如http://localhost/5p_front/we-are-5p-group可以很好地工作。

但是我有一個產品內頁http://localhost/5p_front/product/10如果我將鼠標懸停在菜單項,讓我重定向到登錄頁面,其顯示的URL http://localhost/5p_front/product/5p_group_login因此,當我點擊它,我不能在http://localhost/5p_group/爲重定向它只是recirecting到這個目前的網址只有http://localhost/5p_front/product/5p_group_login不應該是這種情況。

此外,我的菜單是動態快到了,我已經使用Static Pages插件創建菜單,這些菜單OctoberCMS提供和我創建像下面「登錄」菜單鏈接。

enter image description here

我如何可以重定向URL在http://localhost/5p_group/即使用戶是在http://localhost/5p_front/product/10和「登錄」鏈接點擊該圖是http://localhost/5p_front/product/5p_group_login如果我鼠標懸停時就可以了。

有人可以指導我在這裏我應該怎麼做在這種情況下。

感謝

回答

1

您的規則

RewriteRule ^5p_group_login.*$ http://localhost/5p_group [L,R=301] 

放在5p_front/.htaccess時,只會影響到與/5p_front/5p_group_login(因爲在你的模式領先^的),所以/5p_front/product/5p_group_login不匹配開頭的URI。

如果你想重寫有5p_group_login anyhwere的網址,只需使用:

RewriteRule 5p_group_login http://localhost/5p_group [L,R=301] 
+0

哇..很好的解釋。謝謝。 –