4

Question

Is it possible to mass upload 301 redirects?

Situation

I have to create about 950 different 301 and 302 redirects for a public force.com site. From my point of view, it looks like a waste of time to do it manually. Maybe you can help me.

3

You can update a Force.com Site through the metadata API. If you are using MavensMate, Eclipse, or the plain old ant migration tool, you can edit the Site's XML file directly and then save or deploy to your server.

It's in the NameOfSite.site file, the <siteRedirectMappings> element which is a child of the <CustomSite> element. For example, the following adds one Permanent (301) and one Temporary (302) redirect.

<siteRedirectMappings>
    <action>Permanent</action>
    <isActive>true</isActive>
    <source>/abcd</source>
    <target>/test</target>
</siteRedirectMappings>
<siteRedirectMappings>
    <action>Temporary</action>
    <isActive>true</isActive>
    <source>/xyz</source>
    <target>/test2</target>
</siteRedirectMappings>

If you already have them in an Excel file or something like that, I'm sure you could easily automate the building of the XML elements to avoid mass entry.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.