问题
I want to redirect my broken index.html
files from sub folders to home page using htaccess
Example:-
http://blogs.hds.com/hdsblog/category/
http://blogs.hds.com/hdsblog/category/sustainability/page/
are broken links (reported by Google Webmaster). These do not exist.
I want to update my htaccess file, so that URLs like these automatically redirect to the home page of my site.
回答1:
You can use a simple RewriteRule for these URLs
RewriteRule ^hdsblog/category/ / [R,L]
This redirects all requests starting with /hdsblog/category/
, including /hdsblog/category/sustainability/page/
to your home page http://blogs.hds.com/
.
If you want to redirect only these exact requests, you must specify multiple RewriteRule
s
RewriteRule ^hdsblog/category/$ / [R,L]
RewriteRule ^hdsblog/category/sustainability/page/$ / [R,L]
来源:https://stackoverflow.com/questions/15481813/redirect-broken-index-html-files-to-home-page-using-htaccess