301 Redirect

Can anyone help me? We have moved from beaconelectricalservice.com to prolectricllc.com. I want to write a 301 redirect in my htaccess file that will get everything to redirect.

right now I have:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.prolectricllc.com/$1 [R=301,L]

And it redirects the main url. BUT how do you get the individual links to redirect to the new pages. The new pages are not named the same;

Original : www.beaconelectricalservice.com/electricianfriendswood.html
New: http://www.prolectricllc.com/electrician_friendswood.html

I have the individual pages indexed by google so in the SERP’s they click the electricianfriendswood.html link and they get a 404

How can I get all pages to redirect?

Please offer specific instructions as I don’t have much experiences with htaccess

Thanks for your help in advance!

I ended up redirecting each page individually to the new page.

It’s working now, but was there an easier way to accomplish this?


Either of the above code samples will do just that for you.



it doesnt work in my end.

I ended up redirecting each page individually to the new page.

It’s working now, but was there an easier way to accomplish this?

Since one old page goes to some otherly-named new page, would a rewrite map be of use here?


First, welcome to SitePoint’s Apache forum.

Second, was that a question?


I believe the page names remained the same, just the domain changed. With no response back from the OP, I’m guessing that the problem is solved.

BTW, use of a RewriteMap requires access to the httpd.conf so this is not available to most people (certainly not to those who don’t know to ask about it). That’s for good reason: You can take down the entire server if the script is not properly written!



Ah. I asked because link1 in the OP is
and the second was
as well as new domain name.

Besides rewrite map, and besides manually redirecting each file that got a new name, is there… some other way?

I dunno if this would work, but on Unix you can take a file and make it a link to another file. Could something like that be done?

ln electricianfriendswood.html electrician_friendswood.html 



Good catch! I didn’t see that (either)! No, when someone does NOT plan changes like that, it can (and generally does) end up in a disaster).

Yes, I suppose that symbolic links would work but they are a lot of work in themselves, aren’t they? IMHO, do the same work as for a RewriteMap and put it in a PHP script which can read the “map” in a database and perform a header(‘location:’) redirection - but ONLY if you fail to maintain the same filenames!