Christian
Christian

Reputation: 755

rewriterule redirect folder

After all of the research, I have not been able to find the answer to this.

On the old website, html files were the format http://www.example.com/folder/file.html I built the new site in wordpress with the url format http://www.example.com/folderfile/ I have had no problem stripping the .html off with a rewriterule, but how can I remove the / after folder? Is there any way to make

http://www.example.com/folder/file.html redirect to http://www.example.com/folderfile/ automatically?

Any advice is appreciated! Thanks!

Upvotes: 3

Views: 1409

Answers (3)

Christian
Christian

Reputation: 755

This works well:

 RewriteRule ^moreinfo/(.*)$ /moreinfo$1 [R=301]
 RewriteRule ^healthsolutions/(.*)$ /healthsolutions$1 [R=301]

Where /moreinfo/ and /healthsolutions/ are the folders

Upvotes: 0

Felipe Alameda A
Felipe Alameda A

Reputation: 11799

I think all you need is something like this:

RewriteEngine On
RewriteRule .* http://www.example.com/folderfile/ [L]

http://www.example.com/folder/file.html redirects to

http://www.example.com/folderfile/

Upvotes: 0

Stranger
Stranger

Reputation: 223

Try out this:

RewriteRule ^(.*)/(.*).html$ ./$1$2/ [QSA]

Upvotes: 1

Related Questions