Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


BinaryLimited

796 posts

Ultimate Geek
+1 received by user: 80

Trusted

#133402 21-Oct-2013 12:02
Send private message

Does anyone know the code for a full 301 redirect?

eg. olddomain.com/*  ( all pages) redirect to newdomain.com with different content.




Create new topic
LennonNZ
2459 posts

Uber Geek
+1 received by user: 411

ID Verified
Trusted

  #919095 21-Oct-2013 12:19
Send private message

http://www.howto301redirect.com/htaccess-redirect/





BinaryLimited

796 posts

Ultimate Geek
+1 received by user: 80

Trusted

  #919101 21-Oct-2013 12:29
Send private message

LennonNZ: http://www.howto301redirect.com/htaccess-redirect/




Thanks, tried the "moved entire site"
when i type olddomain.com/randompage, i get taken to newdomain.com/randompage  and get a "404 error, page not found"
All link structures are different, content is different on both sites.

i just need all the pages/links in olddomain.com redirected to newdomain.com homepage.





TwoSeven
1712 posts

Uber Geek
+1 received by user: 304

Subscriber

  #919114 21-Oct-2013 12:34
Send private message

Are you trying to 'forward' to the new sites landing page, or 'redirect' to the site at its new location (including same content)?





Software Engineer
   (the practice of real science, engineering and management)
A.I.  (Automation rebranded)
Gender Neutral
   (a person who believes in equality and who does not believe in/use stereotypes. Examples such as gender, binary, nonbinary, male/female etc.)

 

 ...they/their/them...




BinaryLimited

796 posts

Ultimate Geek
+1 received by user: 80

Trusted

  #919117 21-Oct-2013 12:37
Send private message

TwoSeven: Are you trying to 'forward' to the new sites landing page, or 'redirect' to the site at its new location (including same content)?



Company 1 has taken over company 2.
im trying to redirect any link/url from oldcompany.com to newcompany.com, with 301 and still keeping the backlinks of oldcompany.com.

oldcompany.com has now closed so im looking to hold onto their backlinks and traffic




Inphinity
2780 posts

Uber Geek
+1 received by user: 1184


  #919135 21-Oct-2013 13:00
Send private message

If it's hosted on apache you could simply use mod rewrite to rewrite any url with oldcompany.com in it to newcompany.com's default page.

[code]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.oldcompany.com$ [OR]
RewriteCond %{HTTP_HOST} ^oldcompany.com$
RewriteRule ^(.*)$ http://www.newcompany.com/ [R=301,L]
[/code]

BinaryLimited

796 posts

Ultimate Geek
+1 received by user: 80

Trusted

  #919156 21-Oct-2013 13:08
Send private message

Inphinity: If it's hosted on apache you could simply use mod rewrite to rewrite any url with oldcompany.com in it to newcompany.com's default page.

[code]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.oldcompany.com$ [OR]
RewriteCond %{HTTP_HOST} ^oldcompany.com$
RewriteRule ^(.*)$ http://www.newcompany.com/ [R=301,L]
[/code]


Thanks! i tried that earlier but for some reason it wasnt working right, i think it was cloudflare messing things up?
Works perfect now.

Thanks again!




 
 
 

Move to New Zealand's best fibre broadband service (affiliate link). Free setup code: R587125ERQ6VE. Note that to use Quic Broadband you must be comfortable with configuring your own router.
Inphinity
2780 posts

Uber Geek
+1 received by user: 1184


  #919159 21-Oct-2013 13:11
Send private message

I should point out that due to the ^ operator, it won't rewrite subdomains other than www, so, mysite.oldcompany.com for example wouldn't be redirected. You could either remove the ^ operator (thus just %{HTTP_HOST} oldcompany.com$) which should work though I must admit I've not tested it, or add more conditions for the various subdomains, if there are any.

Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.