2013-08-19 49 views
0

我想爲我的用戶製作自定義URL,以便他們可以讓他們的personnal藝術畫廊顯示時就像在Facebook上顯示用戶的個人資料。例如mysite.com/username將顯示用戶名的畫廊。Apache mod_rewrite .htaccess和條件,以避免重寫,而url mysite.com

所以basicaly我現在所做的就是這樣的事情:??

重寫規則^([A-ZA-Z0-9] *)/ $的index.php FC =模塊&模塊= testmodule &控制器= displaygallery & url = $ 1 [L]

我的畫廊在我的網站上正確顯示,但我無法使用絕對mysite.com顯示索引頁面。我知道我們可以使用條件來避免這種情況,但哪一個呢?

回答

0

所以,當寫這篇文章時,我只是想着我所做的一行,並且找到了解決方案^^!

而不是使用:

RewriteRule ^([a-zA-Z0-9]*)/?$ index.php?fc=module&module=testmodule&controller=displaygallery&url=$1 [L] 

現在,我使用:

RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?fc=module&module=testmodule&controller=displaygallery&url=$1 [L] 

而不是使用*我用+,這是告訴Apache的,它需要至少一個字符以上重寫URL,以便現在一切正常:)