Robin Rodricks
Robin Rodricks

Reputation: 113976

Replacing slashes with dashes in URL Rewriting

How do I accomplish URL rewriting for the following with mod_rewrite in Apache?

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

Answers (1)

hjpotter92
hjpotter92

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

Related Questions