2014-11-16 113 views
0

如何在Apache中使用mod_rewrite完成以下URL重寫?在URL重寫中使用破折號替換斜線

  • 漂亮鏈接:www.mysite.com/pages/category/page/
  • 實際文件:www.mysite.com/html/category-page.html

我只想重寫URL是否含有域和pages目錄。在所有其他情況下,我希望服務器正常工作。

我已經想出了這一點,但想知道如何與破折號替代斜線:

RewriteEngine On 
#Look for the word "pages" followed by a slash, and then the article title 
RewriteRule ^pages/(.+)$ html/$1.html [L] 

回答

1

看看下面的規則集的工作原理:

RewriteEngine On 

RewriteRule ^pages/(.+?)/?$ html/$1.html [N] 
RewriteRule ^html/([^/]+)/(.*)$ html/$1-$2 [N] 
相關問題