0

Hello Im trying to add a default url when entering a website for example:

From this

http://example.com

To this

http://example.com/defaultUrl/

I have tried doing this with JavaScript in the beggining of the page but it just causes an infinite loop and I dont think it's very secure. Is where anyway to do this with PHP? I HAVE TRIED the header() function TOO but it just causes an infinite loop of redirects.

Madtin
  • 109
  • 4
  • 12

1 Answers1

0

Within your index.php file add this code at the top:

header('Location: /defaultUrl/', true, 301);
exit;
Bananaapple
  • 2,984
  • 2
  • 25
  • 38
  • I put this at the very beginning of my index.php and it gives me the 'Too many redirects' error :/ – Madtin Sep 01 '17 at 15:26
  • That would suggest that /defaultUrl/ resolves to /index.php under the hood. Have you set up any rewrites at server level? – Bananaapple Sep 01 '17 at 15:38