Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

301 Redirect vs Rewrite

I have a site that was hosted by someone else all the web pages were .html files. I am now hosting the site and have changed it to a wordpress site. The domain has not changed but obviously all the pages have. What is the best way to redirect all the .html pages to the main url?

like image 852
Renee Avatar asked Jan 31 '13 17:01

Renee


1 Answers

301 Redirect in an .htaccess does not require the mod_rewrite library. It's a much simpler way to redirect, but it doesn't have the flexibility and power you get using the Rewrite rules. If you have a 1-1 mapping with explicit urls you can use the Redirect:

Redirect 301  /path/file.html http://new.site.com/newpath.php

If you're trying to do wild card matching of a number of similar patterns using regular expressions you'll need to use Rewrite.

RewriteRule ^(.*).html$ http://new.site.com/$1.php [R=301,NC,L]

Here's a pretty good overview of the 2 methods: http://www.ksl-consulting.co.uk/301-redirect-examples.html

like image 80
Ray Avatar answered Oct 04 '22 00:10

Ray