include function with mode rewrite?

Discussion in 'PHP' started by baris22, Nov 7, 2007.

  1. #1
    Hello all,

    I am using this to include a page
    
    
    $homepage = "http://www.x.com/video_files.html";
    $currentpage = $_SERVER['REQUEST_URI'];  
    if($homepage==$currentpage) {
    include('ads.php');
    
    PHP:
    I started using mode rewrite. When I go to the second page my url changes to http://www.x.com/2/video_files.html

    So, how can i still use include function.

    Thanks
     
    baris22, Nov 7, 2007 IP
  2. DooBDee

    DooBDee Active Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #2
    Is the filename always going to be called video_files.html? If so, you can use $_SERVER['SCRIPT_NAME'] and use strpos() to check for video_files.html :)
     
    DooBDee, Nov 7, 2007 IP
  3. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks DooBDee for the reply.

    Yes it will be always called video_files.html.
    First page is called

    http://www.x.com/video_files.html

    second page is

    http://www.x.com/2/video_files.html

    and so on.

    My php knowledge is not great. How can i use $_SERVER['SCRIPT_NAME'] on my code?

    Thanks
     
    baris22, Nov 7, 2007 IP
  4. DooBDee

    DooBDee Active Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #4
    Try this code;

    $position = strpos($_SERVER['PHP_SELF'], 'video_files.html');
    if ($position)
    {
    	include('ads.php');
    }
    PHP:
     
    DooBDee, Nov 7, 2007 IP
  5. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    it did not work :(
     
    baris22, Nov 7, 2007 IP
  6. DooBDee

    DooBDee Active Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #6
    Try changing PHP_SELF to SCRIPT_URL in the code above :)
     
    DooBDee, Nov 7, 2007 IP
  7. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #7
    no luck again..
     
    baris22, Nov 7, 2007 IP
  8. DooBDee

    DooBDee Active Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #8
    Weird. I just tested this snippet and it works here. Can you PM me or share the address of your site? Try REQUEST_URI instead of the above SCRIPT_URL or PHP_SELF.
     
    DooBDee, Nov 7, 2007 IP
  9. clinton

    clinton Well-Known Member

    Messages:
    2,166
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    110
    #9
    try using SCRIPT_NAME
     
    clinton, Nov 7, 2007 IP
  10. DooBDee

    DooBDee Active Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #10
    Was just about to edit my post to suggest that one! REQUEST_URI should work ok. This was being used previously in your code anyway. :)
     
    DooBDee, Nov 7, 2007 IP
  11. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #11
    I am trying on local. I did not try on the server.
     
    baris22, Nov 7, 2007 IP
  12. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #12
    Thank god I am sorted.

    
    
    $currentpage = array_shift(explode('?', basename($_SERVER['REQUEST_URI']))); 
    $page = "video_files.html"; 
    if ($currentpage == $page) 
    { 
    include ('ads.php'); 
    }
    
    
    PHP:
     
    baris22, Nov 7, 2007 IP
  13. nshahidch

    nshahidch Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Dear how can we configure wamp or phptriad for mod_write.
    I have both of them Installed but they didn’t works…

    Can you tell me how can we configure it…
     
    nshahidch, Nov 13, 2007 IP
  14. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #14
    If you are using latest version of phptriad, it should work. You do not need to do anything.
    Just double check the httpd.conf file which is in AppServ\Apache2.2\conf

    Delete the ";" at the beginning of

    LoadModule rewrite_module modules/mod_rewrite.so

    Restart your apache and it should work.
     
    baris22, Nov 14, 2007 IP
  15. nshahidch

    nshahidch Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    I am using PHPtride .2.1
     
    nshahidch, Nov 16, 2007 IP
  16. nshahidch

    nshahidch Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16

    I have # sign in the begininng of that...
    I have removed it but yet it did not working...

    Please tell me how can I check whether it is enabled or not....
     
    nshahidch, Nov 16, 2007 IP