Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441

    Few PHP Problems

    I'm working on http://commencenow.com , getting the layout ready for launch. I want to achieve Search-Engine-Friendly URLs by having .htaccess treat cn as cn.php, then having PHP handle the path info. However, this only works partially, and when I include files, it messes up the paths, so the scripts mess up when I don't use absolute paths. Could anyone help out with some advice?

    http://commencenow.com/source.php?file=index.php

    You can also view 'cn' and 'db/index.php' ONLY.

    Thanks!

  2. #2
    Join Date
    May 2002
    Location
    UK
    Posts
    2,994
    Having .php does not affect your search engine rankings. Query strings do in some search engines but pretty much all of them actually index query string'd pages.

    However I'd do the thing you're looking for directly in PHP rather than .htaccess by comparing $_SERVER['QUERY_STRING'] against $_SERVER['PHP_SELF']

  3. #3
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    How would you do it directly in PHP?

    I didn't mean .php, but I was referring to the query string.. like you said, most do, but this keeps the page universally safe and is also much easier for clients to remember.

  4. #4
    PHP should work on the filesystem whereas .htaccess directives should work on http requests so I am surprised you are having trouble with filesystem includes.

    I have been working with mod_rewrite recently doing a similar thing and I used a few definitions within a config file (which I included using relative paths with no problems) e.g. $path_from_root and $image_dir this solved the problems I was having when linking to images and stylesheets etc.

  5. #5
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    True, but it's still a lot of unnecessary code..

  6. #6
    Not quite sure I follow?

    By assinging a couple of extra variables and prepending these on to your URLs I don't see it as being excessive code.

    I jst did....

    $scriptroot = '/myapp/dir';
    $imagedir = $scriptroot . '/images';

    Then any href links were defined as...

    "<a href=\"{$scriptroot}/some/thing/\">"

    and images as.....

    "<img src=\"{$imagedir}/icons/new.gif\">"

    Then no matter where the server thinks it is, the files will always be pulled from the right place.

  7. #7
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    That would work, I guess I'm just more partial to relative paths. *back to the work board*

Posting Permissions

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