2013-04-10 85 views
1

我是htaccess規則的新手。mod_rewrite使用.htaccess重寫url php

我想要一個規則,將兩個網址視爲一個。

這兩者應被視爲同一個URL。我只想將sites/client1添加到實際上什麼都不做的URL。每個URL請求都應該包含sites/client1 /。

對於像

  • multisite2 /的index.php?id_product = 1個&控制器=產品
  • multisite2 /站點/客戶端1 /的index.php?id_product = 1個&控制器=產品
下一個請求

感謝您的幫助。

+0

http://domain.com/文件夾/多站點/網站/ client1/index.php應該被視爲http://domain.com/folder/multisite/index.php – 2013-04-10 05:41:21

回答

1

試試這個:

RewriteRule index.php?(.*) sites/client1/index.php?$1

也請了一下週圍搜索張貼在這裏了。這個問題的一些可能的重複是這些:

.htaccess URL rewrite with one and two query string vars

htaccess url rewrite to .php

+0

嗨mtndesign,感謝您的幫助。 它現在實際上重定向到sites/client1/index.php。 我不想要這個,我只是想在URL中顯示它。但內部它應該留在http://domain.com/folder/multisite/index.php 再次感謝 – 2013-04-10 06:01:39

+0

sites/client1 /只是虛擬參數 – 2013-04-10 06:16:22

+0

你的意思是你不想重定向用戶,你只是想將'sites/client1/index.php'作爲'index.php'來處理?那麼你應該更新你的問題。作爲解決方案,您應該使用'mod_proxy'。檢查apache文檔,並看看以下問題:[q1](http://stackoverflow.com/questions/5206201/why-redirect-keeps-changing-address-bar)[q2](http:// stackoverflow。 COM /問題/ 4645280 /重寫的URL,而無需改變地址)。如果您需要任何代碼,我可以提供給您。 – mtndesign 2013-04-10 06:33:14

1

這將在/網站/客戶端1發送的所有請求/到/

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteRule ^sites/client1/(.*)$ $1 [L,QSA] 
</IfModule> 
+0

嗨silentboy,謝謝你的幫助。它現在實際上重定向到/的相同問題。簡單地說,/ sites/client1 /應該保留在URL中,但在內部它應該調用domain.com/folder/multisite/index.php – 2013-04-10 06:13:06

+0

sites/client1 /只是虛擬參數 – 2013-04-10 06:16:55

+0

傾銷這個想法.. – 2013-08-16 10:09:44