2011-11-13 29 views
0

我一直在使用這樣的規則:如何Mod_Rewrite整個URL路徑?

RewriteRule ^([^\.]+)/?$ index.php?page=$1 [L] 

這會變成

example.com/page/hello 

...到

example.com/index.php?page/hello 

但是,如果我有更重要的是結束一個文件擴展名,說,

example.com/page/hello/doc.html 

...它不起作用。我怎樣才能使該URL成爲:

example.com/index.php?page/hello/doc.html 

...和

example.com/page/ 

...成爲:

example.com/index.php?page/ 

非常感謝你,如果你能幫助這個。我試過擺弄正則表達式,但我不能讓它工作。

謝謝。

回答

1

您正則表達式的這一部分將匹配的是除了一個句號任何一個或多個字符:

[^\.]+ 

如果你想匹配一個或多個任意字符,然後只寫:

.+ 

改爲