Phillip Mclauren
Phillip Mclauren

Reputation: 417

Redirecting URL using .htaccess

I have a WordPress website and some link checker plugins are reporting all the links broken in same way. Just have a look:

http://www.esmedicare.com/category/blog/page/2/locations.html ( parent page: http://www.esmedicare.com/category/blog/page/2/ )
http://www.esmedicare.com/hello-world/locations.html ( parent page: http://www.esmedicare.com/hello-world/ )
http://www.esmedicare.com/neonatal-care-2/locations.html ( parent page: http://www.esmedicare.com/neonatal-care-2/ )
http://www.esmedicare.com/dental-center/locations.html ( parent page: http://www.esmedicare.com/dental-center/

I just want to redirect all these pages to their parent pages shown in bracket but I dont know how to do it exactly.

Please help me to solve this.

Upvotes: 1

Views: 98

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

Try adding these rules in the htaccess file in your document root, above any wordpress rules:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/locations.html$ /$1/ [L,R=301]

Upvotes: 2

Related Questions