Reputation: 113976
How do I accomplish URL rewriting for the following with mod_rewrite
in Apache?
www.mysite.com/pages/category/page/
www.mysite.com/html/category-page.html
I only want to rewrite URLs if they contain the domain and the pages
directory. In all other cases I want the server to work normally.
I've come up with this but would like to know how to replace slashes with dashes:
RewriteEngine On
#Look for the word "pages" followed by a slash, and then the article title
RewriteRule ^pages/(.+)$ html/$1.html [L]
Upvotes: 0
Views: 117
Reputation: 80639
See if the following rule set works:
RewriteEngine On
RewriteRule ^pages/(.+?)/?$ html/$1.html [N]
RewriteRule ^html/([^/]+)/(.*)$ html/$1-$2 [N]
Upvotes: 1