Jump to content

[SOLVED] Loading from webroot


acctman

Recommended Posts

hi is there a way to code into php so a file in /loc/files/page1.php , I dont have to type out header('Location: www.site.com/loc/files/page1.php'); or header('Location: /../../page1.php'); or this method which would require me to include a file each time header('Location: $site . '/loc/files/page1.php');

 

I'm editing files on a test site and I will be moving them over to the live site, and don't want to have to change out all the URLs to the live site. any ideas?

 

Link to comment
https://forums.phpfreaks.com/topic/120896-solved-loading-from-webroot/
Share on other sites

If /loc/files/page1.php is the web root you can simply do this:

 

header("Location: /loc/files/page1.php");

 

no need to enter http:// or www.yourdomin.whatever

I use this method when protecting my image and archive folders.

 

you're probably thinking of include() - header() sends the user to that URL directly, which in this case would be invalid.  acct, sorry to say, but you'll need to use one of the methods you don't like, be they symbolic links, hard-coded site URL or included site URL.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.