Hi, I have something like window.location='http://www.dgoya.com/admin/p.php?p=Letters&page=<?=$_GET['page']?>'; I wanted the above code changed so the http://www.dgoya.com/ is not there. So when I reuse the script in other websites, it takes up that url. As of now I had to hardcode the URL. How can I make it appear automatically? Thanks
You could put it in as a variable and store its value in a config file ? Example open config.php assuming you have one ? put something like : $siteURL = "http://domainName.com"; // No forward slash / Code (markup): ..and then within your files where your need a doman name to show, like your above code, put: window.location='$siteURL/admin/p.php?p=Letters&page=<?=$_GET['page']?>'; Code (markup): You might need to mess-around with that so it echo's the $siteURL correctly
Thanks MyVodaFone. That was perfect. I got no clue how to fix this and was browsing about this a lot and did not find aright fix. It was perfect fix for my requirement. Thanks a lot.
This will echo the domain name where the page is loaded. If you want to use this code on several different domain names, this will be the easier way to do it: <?php $siteURL = $_SERVER['HTTP_HOST']; window.location='http://<?php echo $siteURL; ?>/admin/p.php?p=Letters&page=<?=$_GET['page']?>'; Code (markup):