2011-06-16 30 views
0

我在我的.htaccess文件中有下面的代碼,頂部的重寫工作正常,但我不知道爲什麼,但我不知道如何解決它。php到html .htaccess幫助

及其看到重寫規則^([^ /] *)。HTML的index.php?p值=順序& COURSE_ID = $ 1 [L]爲監守的hightlighed部的頂部重寫命令和我不希望把它在上

重寫規則^([^ /。] +)。HTML 的index.php?p = $ 1 [L]一DIR

RewriteEngine敘述

index.php?p=about_us 

RewriteRu樂^([^ /] +)。HTML 的index.php?p =順序& COURSE_ID = $ 1 [L]

index.php?p=order&course_id=5 

謝謝

+0

不知道我得到這個矩陣,因爲你的兩個規則的LHS條件是相同的^^[[^ /] +)。html'? – anubhava 2011-06-16 18:15:06

回答

0

你能給例如網址應匹配模式塊和你希望他們被重寫的內容?這將是非常有益的。

有一兩件事我注意到的是你,如果你的模式塊與+這意味着1次或多次匹配,第二個你一個*這意味着0個或更多,所以我不檢查測試你的第一正則表達式認爲第二個將被稱爲,雖然我對正則表達式非常陌生,但它只是我注意到的東西。

這些都是非常有用的資源對我來說:

http://www.webforgers.net/mod-rewrite/mod-rewrite-syntax.php

http://forum.modrewrite.com/

+0

index.php?p = about_us ||| index.php?p = order&course_id = 5 – Rickstar 2011-06-16 16:48:46

+0

@Gully好吧,所以你想要domain.com/about_us變成domain.com/index.php?p=about_us我想,但第二個呢? – 2011-06-16 17:01:15

0

從您將要使用的URL的例子,這應該工作:

# http://website.com/about_us/ rewrites to /index.php?p=about_us 
RewriteRule ^([0-9a-z_-]+)/?$ index.php?p=$1 [NC,L] 

# http://website.com/order/12/ rewrites to /index.php?p=order&course_id=12 
RewriteRule ^order/([0-9]+)/?$ index.php?p=order&course_id=$1 [NC,L] 

第二重寫可能是:

# http://website.com/order/12/ rewrites to /index.php?p=order&course_id=12 
RewriteRule ^([0-9a-z_-]+)/([0-9]+)/?$ index.php?p=$1&course_id=$2 [NC,L] 

取決於您的頁面結構。