
08-28-2006, 05:29 AM
|
|
Newbie
|
|
Join Date: Aug 2006
Posts: 13
|
|
Hi all,
I have a script that is locked to my domain. It is no longer supported and therefore I cannot change this domain lock. The license requires access to the script by having a www in the address not just http
Therefore users trying to access the script without www in the address are displayed an error message. Is there a code I can insert into the index page so if the user accesses it without www in the address it will redirect to the same index page but by including www in the address.
Sorry I cant be more specific, currently im not certified to post urls so its made it a little hard to explain my situation easily.
Im hosted on a windows server so believe I cannot use .htaccess, any help will be greatly appreciated as my php knowledge isnt very good.
Thanks
|

08-28-2006, 08:51 AM
|
|
Junior Guru
|
|
Join Date: Jan 2005
Location: Leeds, England
Posts: 183
|
|
Welcome to WHT!
all i can suggest is you put an index.html page in there along with it with meta tags in that redirect it to www.
Code:
<html><head><META
http-equiv="refresh" content="2;URL=http://www.yourdomain.com/index.php"></head><body> <center>If you are not redirected to the site within 2 seconds <a href="http://www.yourdomain.com/index.php">Click Here</a></body></html>
there's the html code for the whole page.
there is also a way to do it via the php script however you haven't posted the source for ti so we can't really help you with something to put in the php script
also this thread should be in the programming discussion forum as it's not a tutorial 
Last edited by Omega-Mark; 08-28-2006 at 08:56 AM.
|

08-28-2006, 08:56 AM
|
|
Performance Specialist
|
|
Join Date: Dec 2004
Location: New York, NY
Posts: 10,338
|
|
You can also use PHP:
PHP Code:
<?PHP header("Location: http://www.example.com/"); exit ?>
|

08-28-2006, 10:12 AM
|
|
Newbie
|
|
Join Date: Aug 2006
Posts: 13
|
|
Thanks to the both of you for replying.
This was my first post on this forum and therefore could not post direct links or use the PHP tags, I figured it would be abit messy if I just posted the contents of the index.php straight into the thread post.
Do you just need the first few lines or the whole file (635 lines) ?
A index.html file wouldnt be beneficial really as it wouldn't solve the problem if the user typed in the address but only omitted the www part.
Sorry for posting in the wrong thread, figured programming discussion would be the most likely place, didnt realise I was in the tutorial sub-forum though, could a mod please move this to the relevant location please.
layer0: Do I simply paste that code into the index.php file and enter the location I want it to redirect to?
Thanks again to you both
|

08-28-2006, 11:54 AM
|
|
Newbie
|
|
Join Date: Aug 2006
Posts: 13
|
|
I have also posted a support ticket to my webhost, although its strictly not his responsibility to support this kind of question he is a helpful guy and may sort something out for me.
Any other suggestions would be appreciated. The script does call a config file, perhaps a code could be placed in there to avoid looping in the index file.
|

08-29-2006, 12:13 PM
|
|
Junior Guru
|
|
Join Date: Jan 2005
Location: Leeds, England
Posts: 183
|
|
Quote:
|
Originally Posted by erystiva
Thanks to the both of you for replying.
This was my first post on this forum and therefore could not post direct links or use the PHP tags, I figured it would be abit messy if I just posted the contents of the index.php straight into the thread post.
Do you just need the first few lines or the whole file (635 lines) ?
A index.html file wouldnt be beneficial really as it wouldn't solve the problem if the user typed in the address but only omitted the www part.
Sorry for posting in the wrong thread, figured programming discussion would be the most likely place, didnt realise I was in the tutorial sub-forum though, could a mod please move this to the relevant location please.
layer0: Do I simply paste that code into the index.php file and enter the location I want it to redirect to?
Thanks again to you both
|
just paste the code that layer0 suggested tot he top of your script.
|

09-01-2006, 03:12 AM
|
|
Newbie
|
|
Join Date: Aug 2006
Posts: 13
|
|
Thanks for confirming that for me Omega-Mark
|

09-05-2006, 02:38 AM
|
|
New Member
|
|
Join Date: Sep 2006
Posts: 3
|
|
.. or you can use .htaccess redirect,
redirect 301
|

09-09-2006, 03:51 AM
|
|
Web Hosting Master
|
|
Join Date: Jun 2003
Posts: 629
|
|
an htaccess redirect is probably the quickest and easiest way to do that, just add
Redirect / http : / / www dot whatever you want dot com
(obviously take out the spaces in the url)
|

09-09-2006, 03:54 AM
|
|
Newbie
|
|
Join Date: Jan 2006
Posts: 21
|
|
Few Suggestions:-
I Report this Bug to Developer of this system rather your hosting company. It is one min job to solve.
II Rename the Main Index.php to anything.php and add this code
[PHP
<?PHP
// filename: index.php
header("Location: http://www.example.com/anything.php");
?>
[/PHP]
|

09-21-2006, 10:04 PM
|
|
Junior Guru Wannabe
|
|
Join Date: Jan 2006
Posts: 40
|
|
Add code below to top of index.php or config.php file:
PHP Code:
if ($_SERVER['HTTP_HOST']!="www.YourDomain.com") {
header("location: http://www.YourDomain.com");
}

|

09-22-2006, 05:12 AM
|
|
Newbie
|
|
Join Date: Jul 2006
Posts: 19
|
|
Quote:
|
Originally Posted by RACKSET
Add code below to top of index.php or config.php file:
PHP Code:
if ($_SERVER['HTTP_HOST']!="www.YourDomain.com") { header("location: http://www.YourDomain.com"); }

|
If we use upper script for this:
PHP Code:
if ($_SERVER['HTTP_HOST']="www.sub-domain.YourDomain.com") { header("location: http://www.YourDomain.com/sub-domain/"); }
Can you tell me "it will run"?
|

09-22-2006, 08:53 AM
|
|
Junior Guru Wannabe
|
|
Join Date: Jan 2006
Posts: 40
|
|
I have not tested that, but you can check it and please send the result.
|

12-29-2006, 02:25 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2006
Posts: 961
|
|
Further to what I stated above,
I would change:
PHP Code:
if ($_SERVER['HTTP_HOST']="www.sub-domain.YourDomain.com") { header("location: http://www.YourDomain.com/sub-domain/"); }
for:
PHP Code:
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") { header("location: https://www.YourDomain.com/sub-domain/"); } else { header("location: http://www.YourDomain.com/sub-domain/"); }

|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|