2011-03-22 60 views
0

什麼是Apache的重寫URL從這個URL中提取ID號碼(434376)?重寫URL規則,例如StackOverflow

http://stackoverflow.com/questions/434376/unique-url-slug 

RewriteEngine On 
RewriteRule ^questions/([0-9]+)/?$([A-Za-z0-9-]+) post.php?post_id=$1 [NC,L] 

...但它並不在我的網站工作...任何提示?

感謝

回答

1

測試:

RewriteRule ^questions/([0-9]+)/?.*$ rewrite.php?post_id=$1 [NC,L] 
0

那麼如果/是可選的,它可能應該是:

RewriteRule ^questions/([0-9]+)/?([A-Za-z0-9-]+)?/?$ post.php?post_id=$1 [NC,L] 

讓我知道,如果它的工作原理..