php - Htaccess look for pattern in url that end in .html and redirect -
so have 404 url in google want redirect user, if user accesses http://example.com/url-that-doesn't-exist-anymore.html
i want them redirected index page, problem can't figure out pattern since new in regex.
it's important note url needs end in .html othwerwise shouldn't redirect. , need specify host in redirect b/c have multiple domains on same app
here tried didn't work:
redirectmatch 301 example.com^/(*)/?$ /
rewriteengine on rewriterule ^oldpage\.html$ http://www.newdomain.com/ [l,r=301] this redirects domain.com/oldpage.html index page or whatever second argument is.
l means it's final redirect bothers with, , sends off straight away. r=301 means it's permanent redirect, , browsers cache it. think search engines take note too.
to redirect html pages on server use
rewriterule ^(.*)\.html$ http://www.newdomain.com/ [l,r=301]
Comments
Post a Comment