2014-11-16 55 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] 
相关问题