Results 1 to 7 of 7

Thread: Please Help

  1. #1
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please Help

    Please Help i need a PHP script, i hace registered my own domai name www.gur.in or htp://www.gur.in and i am hosting my site at cjb.cc and the url for it is http://gtec.cjb.cc i want a script that if someone types http://gtec.cjb.cc in the address bar it sould display a message that the site has new domain name which is gur.in and on my index.htm i have mentioned that i have registered my own domain but it should not appear if someone has typed gur.in in the address bar please help me

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by gur
    [...] i need a PHP script
    Perhaps a better approach would be to use URL rewriting to automatically alter the URL. However, if your intent is to explicitly point out the new domain name, you can check what was used to request a PHP script using the HTTP_HOST server variable.

    PHP Code:
    $_SERVER['HTTP_HOST'
    Exactly how you'd go about using this would depend on how you'd want to present this information.

    If you want a forwarding page, it would probably be necessary to use URL rewriting anyway: rewrite to a common forwarding page which presents a link that can be used to continue to the original with the new domain.

    Before you can even consider using URL rewriting, you must make sure your host supports mod_rewrite with .htaccess files.

    Mike
    Last edited by mwinter; 04-02-2005 at 11:33 PM. Reason: Correction from REQUEST_URI to HTTP_HOST

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I don't do PHP but in JavaScript:
    Code:
    <script>
    if (parent.location.href=='http://gtec.cjb.cc/index.htm') //use the correct filename here
    document.write('your message goes here')
    </script>
    perhaps this can be adapted to PHP.
    Last edited by jscheuer1; 04-02-2005 at 11:34 PM.

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    I don't do PHP but in JavaScript:
    <script>
    if (parent.location.href=='http://gtec.cjb.cc')
    document.write('your message goes here')
    </script>
    perhaps this can be adapted to PHP.
    Yes:

    PHP Code:
    <?php if('gtec.cjb.cc' === $_SERVER['HTTP_HOST']) { ?>
      <!-- Content to insert here. -->
    <?php ?>
    would perform basic content insertion.

    This wouldn't work with HTTP/1.0 clients as they don't send a Host header. However, I don't think there are that many HTTP/1.0 clients left - I'm not honestly sure when HTTP/1.1 became widely implemented.

    if (parent.location.href=='http://gtec.cjb.cc/index.htm') //use the correct filename here
    An alternative would be to do a substring search:

    Code:
    if(-1 != document.URL.indexOf('gtec.cjb.cc')) {
    Mike
    Last edited by mwinter; 04-02-2005 at 11:53 PM.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by mwinter
    if(-1 != document.URL.indexOf('gtec.cjb.cc')) {
    This will always be true as the redirect places that document in a frame. That's why I used 'parent'. I don't know PHP but, if you were assuming that these were two separate documents, your PHP code should be adjusted as well. This is the second time, recently, I've run across redirects being accomplished simply by placing the original document in a frame so, I get the idea it is rather routine. I for one, vote against this tactic.
    Last edited by jscheuer1; 04-03-2005 at 05:11 AM.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I got another one that is even better for detecting the presence of the containing frame.

    Code:
    <script>
    if (parent.location.href==location.href)
    document.write('Your content here');
    </script>
    This will only write the content if the document is not in the redirect (or some other) frame. Now, since we're supposed to be on PHP, can this be done with PHP? Also, in a somewhat related matter, I've noticed that my PHP list program uses extensive JavaScript in its templates yet still performs with JavaScript turned off. Are there some portions of JavaScript that act as server side when used with (or without) PHP, or is the PHP program just compensating when JavaScript is turned off by using different methods?

  7. #7
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    This will always be true as the redirect places that document in a frame.
    Oh, I see. The OP is using cloaking, not redirection. Well no, PHP can do nothing here as the request to the server will always be under the gtec.cjb.cc domain.

    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •