0

I am trying to redirect my addon domain along with custom path to my main domain

here is the script from addon domain's index file:

<script type="text/javascript">
// Javascript URL redirection
    var redirect_url = "http://maindomain.com" + location.pathname + location.search;
    setTimeout( function() {
        window.location = redirect_url;
        }, 1000 );
</script>

When I access addon domain without any path, it successfully redirects it to main domain

BUT

When I add custom path, it gives error. How can I redirect it along with customs paths to my main domain?

Faisal
  • 1,907
  • 1
  • 22
  • 29
  • What error are you getting and can you alert the value of "redirect_url" – Vivek Gupta Mar 11 '15 at 10:00
  • Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@listfeedbuzz.listupon.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. – Faisal Mar 11 '15 at 10:01

2 Answers2

0

Try after encoding url component like

     var redirect_url = 
   "http://listupon.com" + encodeURIComponent(location.pathname) + encodeURIComponent(location.search) ;
Vivek Gupta
  • 955
  • 4
  • 7
  • Tried: Nothing happened, still getting same error: 500 Internal Server Error – Faisal Mar 11 '15 at 10:04
  • can you confirm the value of redirect_url placing a alert in the script – Vivek Gupta Mar 11 '15 at 10:06
  • I am new to JS, can you tell me anyother script that allows redirection of URL with custom path? – Faisal Mar 11 '15 at 10:08
  • Your code should work but I want to know the value of redirect_url just place alert(redirect_url) below and post the value which alert is returning – Vivek Gupta Mar 11 '15 at 10:23
  • I've added alert, when I access http://www.listfeedbuzz.com/, it returns "http://listupon.com/" in alert but when I try to access http://www.listfeedbuzz.com/10-rare-eye-conditions-must-know/ it gives error – Faisal Mar 11 '15 at 10:49
  • In that case my friend the issue is not with your JavaScript its some configuration or server side issue – Vivek Gupta Mar 11 '15 at 10:51
0

Try window.location.href instead of window.location & which server you are using like apache, IIS ? If its apache check your .htaccess file for rewrite url for 500 error