SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Howdy...

    I recently rebulit one of my client sites from SSI to HP/mySQL. I just noticed that some of the SSI pages are still showing up in the search results. I would like to do a redirect from the .shtml page to the more recent .php3 page.

    A sample link coming in would look like this:

    www.plusoneonline.com/bios/nate.shtml

    and should be replaced with this:

    www.plusoneonline.com/bios/nate.php3

    and put inside the frameset.

    I have already done this one manually. I think that this should be easy, but I am unsure of how to begin.

    Let me take a stab at it and then maybe someone could correct me when needed.

    I create a PHP page that reads in the page that is being accessed (what is the varible for that one?). Then I do a string replace getting rid of the .shtml extension and tacking on a .php3 one in it's place. Good so far?

    I already have a page in place called frame.php3. It lets me link to a page from outside the frameset yet will drop the specified page right INTO the frameset. That little dandy will save me some serious time when send links to fans.

    You can see it in action here:

    http://www.plusoneonline.com/frame.p...bios/nate.php3

    So, can someone help me out?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  2. #2
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  3. #3
    SitePoint Member
    Join Date
    Mar 2001
    Location
    Colchester, VT
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use $PHP_SELF to get the current page. It always includes a forward slash at the front of it so use a substr like this $Page=substr("$PHP_SELF", 1) to get rid of it.

    Another option would be to add redirect statements to your webserver's configuration, if you have the access to do so. This may be easier if you only have to redirect a handful of URLs.

    Good luck.

    -Michael

  4. #4
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mcouillard...

    I just noticed that this was your first post. Welcome to SitePoint.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If it is on a UNIX system you can use a .htaccess file to redirect a user automatically. Take a look at http://www.internet-tips.net/Webmast...s_redirect.htm

    Sean

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, are there any other options sean?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  7. #7
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Creole,

    I have two ideas that are possible, but I'm not entirely sure that they'll work:

    1. Create a .htaccess file and inside place:

    Redirect *.shtml *.php3

    (I highly doubt this will work but it is worth a try)


    2. All the requests go to a 404 page right? Well on the page do:
    Code:
    <?php
    if(ereg("([a-zA-Z0-9_\-\&\$\?\(\)])(\.)(shtml)", $HTTP_REFERER, $var)) {
    header("Location: " . $var[1] . $var[2] . "php3");
    } else {
    Print " Page could not be found.";
    }
    ?>

    Now, thats should redirect the user to the appropriate php page if I'm correct, but if you get a parse error then it is with the ereg.

  8. #8
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If apache is running mod_rewrite then you can simply place a rewrite directive in the .htaccess file. This is the simplest and most efficient solution. Don't know what the sytax of the directive would be right off the top of my head but you can find the info at www.apache.org or find a suitable tutorial on the web. Otherwise a 404 redirect script as petemc suggests would be the next best thing.

  9. #9
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes I already sent creole a private message regarding this post and the correct syntax for this would be:

    RewriteEngine on
    RewriteRule ^([A-Za-z0-9]+).shtml?$ http://www.plusoneonline.com/frame.php3?page=bios/$1.php3 [R]
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  10. #10
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Freddy...you never cease to amaze me. Now I have one question. Where should the .htaccess file be located for this to work?

    My site structure is like this:

    /
    /bios
    /images
    /home

    and so on. The structure is never more than 1 folder deep. Should the htaccess file go in the docroot?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  11. #11
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would just put it in the bios directory.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  12. #12
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but what about other pages that need to be redirected? Would it be cool to put an htaccess file in each directory?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  13. #13
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure you might have to change the rewrite rule a bit unless all .shtml pages have names associated with them.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  14. #14
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    every page that WAS .shtml has a .php3 counterpart.

    So unless I have access to the httpd.conf file I have to do it the hard way? Directory by directory?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  15. #15
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .htaccess files work for every directory under em, so put it in the highest directory you can.

  16. #16
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freakysid
    If apache is running mod_rewrite then you can simply place a rewrite directive in the .htaccess file. This is the simplest and most efficient solution. Don't know what the sytax of the directive would be right off the top of my head but you can find the info at www.apache.org or find a suitable tutorial on the web. Otherwise a 404 redirect script as petemc suggests would be the next best thing.
    I was following up on this thread FreakySid and it looks like my Apache server has rewrite running, at least from this quote:

    Apache/1.3.12 (Unix) ApacheJServ/1.1.2 Rewrit/1.1a FrontPage/4.0.4.3 PHP/4.0.3pl1

    Is that what that means?

    Here is the entire list of variables for my apache server:
    http://host3.veoweb.net/modules.cgi
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  17. #17
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The modules shown in the link you give are perl modules.

    Best contact your host about mod_rewrite. Blah, I don't know how to work out which modules are running with Apache - but there must be a way because in Webmin you can see which ones are running. I just looked at my httpd.conf file and in my build of Apache mod_rewrite is not loaded as a DSO (dynamic module) so it must be compiled in.

    BTW, I'm just thinking that you should also check out mod_alias as well. Because mod_alias was written for exactly what you want to do as well.

    All the modules are well documented at http://httpd.apache.org/docs/mod/index-bytype.html


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
  •