function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AndreaTAndreaT 

301 redirect, anything like that?

Any search engine-friendly way to move an existing website to force.com, I mean to handle the change of urls?

 

from 

www.domain.com/abcdefg.asp

to

www.domain.com/abcdefg 

  

 

Thanks 

Best Answer chosen by Admin (Salesforce Developers) 
arunkarunk

Hi,

 

This is how i do redirects from VisualForce pages:

 

 

Page:

 

<apex:page showHeader="false" sidebar="false" controller="RedirectController" action="{!doRedirect}"></apex:page>

 

 

 

Controller:

 

public class RedirectController { public PageReference doRedirect(){ return new PageReference('http://www.google.com'); }}

 

 

 Regards,

 Arun 

All Answers

RyanGuestRyanGuest
You can't currently send 301 or 302 redirects with Force.com Sites.
AndreaTAndreaT

Yes I know.

So, suppose there's no tool like that.

Yet, any best practice or suggestion or way to work around that?

 

Such a loss would prevent us from migrating existing websites to force.com  

 

Richie DRichie D

A hack could be to have a 'page not found' VF page in your site that takes the request url, trims off the trailing .*** and then redirects to that page.

 

You'll have to use JavaScript to do this I think.

 

something like:

 

<script type="text/javascript">var str= new String(document.location.href);var i = str.lastIndexOf('\.');if(i > -1)document.location.href = document.location.href.substring(0, i);</script>

 

 

Hope this helps.

 

R. 

 

BulentBulent
Alternative to the javascript, you can have a custom controller on the page not found page to do the same via apex. 
arunkarunk

Hi,

 

This is how i do redirects from VisualForce pages:

 

 

Page:

 

<apex:page showHeader="false" sidebar="false" controller="RedirectController" action="{!doRedirect}"></apex:page>

 

 

 

Controller:

 

public class RedirectController { public PageReference doRedirect(){ return new PageReference('http://www.google.com'); }}

 

 

 Regards,

 Arun 

This was selected as the best answer
AndreaTAndreaT

Hello,

Does anyone know if the 301 feature is going to be released with Spring '10?

Thanks

 

 

Marek ZapletalMarek Zapletal
Hi All,

I am solving 301 Permanent redirect but it looks like there is nothing new in Force.com Sites since 2009?
I am getting some javascript 200 redirect using pageReference object..
Thank you