2012-03-09 110 views
0

我使用此RewriteRule ^page/([0-9]+)/ page.php?id=$1更改URL http://example.com/page.php?id=00001http://example.com/page/00001/雖然任何圖像或CSS/JS /等頁面沒有正確鏈接了。問題與URL重寫規則

EG:http://example.com/_img/image.jpg變成http://example.com/page/00001/_img/image.jpg

有沒有辦法改變整個目錄呢?例如,我試過這個:

RewriteRule ^page/([0-9]+)/(.*?) $2 

但是,這並沒有奏效。謝謝您的幫助!

編輯:
好吧,這似乎工作,但根據這只是其中的一個工作是第一位。

RewriteEngine on 

RewriteRule ^page/([0-9]+)/(.*)$ $2 
RewriteRule ^page/([0-9]+)/ page.php?id=$1 

這樣,它忽略了第二個,所以http://example.com/page/00001/是現在http://example.com/index.php?id=00001代替http://example.com/page.php?id=00001
是否有可能爲它也考慮到第二個?

+0

在'HTTP的情況下:// example.com /頁/ 00001 /'都重寫規則將適用。你會在最後一個斜槓後面輸入什麼樣的信息? – 2012-03-09 18:39:22

+0

http://example.com/page/00001/_img/或任何應該重定向到http://example.com/_img/的內容。基本上,我想http://example.com/page/00001/重定向到http://example.com/page.php,但其他任何只是http://example.com/whatever – 2012-03-09 18:42:54

+0

啊,沒關係。修復。謝謝! :) – 2012-03-09 18:45:33

回答

0

Mayby像這樣的工作:

RewriteEngine On 

RewriteRule ^page/([0-9]+)/(.+)$ $2 
RewriteRule ^page/([0-9]+)/?$ /page.php?id=$1