Reputation: 1
I want to do a 301 redirect for my site URL's like http://example.com/old-folder/allhtmlfiles.html to http://example.com/new-folder/allhtmlfiles.html.
All html files under old-folder should be accessible with the /new-folder/
How can I do this, I tried some solutions I found here but they were giving me 404 errors.
Thanks for your help.
Suzy Matts
I changed my .htaccess accordingly but does'nt work. I think I had not clearly mentioned the slug change in my previous question.
This was the actual previous link in this wordpress site,
http://dland.in/sale/land-in-madikeri-karnataka-state-india-1750-acre/
and now the folder name has changed and this is the new link
http://dland.in/kerala-real-estate-sale/land-in-madikeri-karnataka-state-india-1750-acre/
the second slug (land-in-madikeri-karnataka-state-india-1750-acre) can be any
so I want to get a 301 redirect to the new link.
Thanks a lot.
Upvotes: 0
Views: 136
Reputation: 7739
I did some changes on the content of the htaccess you posted (removed the duplicated rewrite base and moved the sale rule first), try this :
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteRule ^sale/(.*)$ dland.in/kerala-real-estate-sale/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Upvotes: 0
Reputation: 143856
Put this in the htaccess file in your document root:
RewriteEngine On
RewriteRule ^old-folder/(.*)$ /new-folder/$1 [L,R=301]
Upvotes: 1