SharePoint 2013 landing page redirect

Nozipho Ngcobo (IT Department) 21 Reputation points
2022-06-30T19:16:38.793+00:00

Hi There

Is this script safe to use to redirect my SP2013 home page to SPO? It works in my dev environment but can I apply it to my prod environment?
216597-19eeaf60-514a-4369-98c0-8d7187eb0ee5.png

Microsoft 365 and Office | SharePoint | Development
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 40,476 Reputation points Microsoft External Staff
    2022-07-01T13:11:40.903+00:00

    Hi @Nozipho Ngcobo (IT Department) ,
    Per my research, using location.href can be understood to include two things:

    Using the value of location.href by passing it around in your code, manipulating it and using it to guide the logic in your code.
    Assigning someting to location.href, causing the browser to navigate to different URLs.
    The first one, using the value, can be considered safe. The value of location.href is nothing more than a string. Of course it's part of user input, so you don't want to pass it to an eval statement, but that's true for all other forms of user input as well. In fact, the value of location.href is always a valid URL, so certain assumptions can be made of its content. In that sense you could argue it's more safe than most forms of user input. As long as you don't make any wrong assumptions.

    The second one is something you should be careful with. Assigning unvalidated values to it can lead to open redirects that can be used for phishing and what's more, XSS issues arising from the use of javascript and vbscript URIs.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nozipho Ngcobo (IT Department) 21 Reputation points
    2022-06-30T20:10:52.123+00:00

    Tried this script on production and it worked!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.