Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    113
    Thanks
    6
    Thanked 1 Time in 1 Post

    Dillema - clean URL without mod-rewrite or multiview

    Look at these two URLs (example):
    1: http://codingforums.com/newthread.php/new
    2: http://codingforums.com/newthread/new

    Both #1 and #2 contain this code.
    <?php
    echo $_SERVER['REQUEST_URI'];
    ?>

    Of course since #2 is a dir, the code is inside a index.php file.

    The problem is #1 works and #2, my preferred method, doesn't work.

    I've been googling around for a while and found two solutions to this: mod rewrite and multiview, but these require sever config.

    I would like to know if there is a way to accomplish this without configuration, just PHP.

  • #2
    Regular Coder funnymoney's Avatar
    Join Date
    Aug 2007
    Posts
    364
    Thanks
    17
    Thanked 24 Times in 24 Posts
    there is a way without mod rewrite but you would still need .htaccess file. i'm not sure is it possible to force no extension to be parsed as .php file without tempering with default server settings or using that .htaccess scheme

  • #3
    Regular Coder
    Join Date
    Feb 2007
    Posts
    113
    Thanks
    6
    Thanked 1 Time in 1 Post
    In #2, "newthead" is an actual folder not a file so I'm NOT looking for a way to mask the PHP extension.

  • #4
    Regular Coder funnymoney's Avatar
    Join Date
    Aug 2007
    Posts
    364
    Thanks
    17
    Thanked 24 Times in 24 Posts
    then #2 should be 2: http://codingforums.com/newthread/index.php/new , but the whole point of url rewriting and clean urls is that they are clean, and that they obscure(i think it's proper word) website folder structure and language used to create it.. eg, you can use asp but add .php extension so that eventual hacker tries injecting malicious php code into your ASP script.

    in your #2 server looks for "newthread" folder, and then looks for "new" folder inside that "newthread" folder, if settings are default of course it will not work..

    you can try this without anything

    http://www.example.com/index.php/something/really/cool that will fill your $_SERVER['request_uri'] var, and http://www.example.com/index/something/really/cool will fail, couse server thinks index is folder...

    all in all you only need one index file, or anyother name script file, and never ever need to show real folder structure, except when loading images or image-like files
    Last edited by funnymoney; 05-11-2009 at 08:38 PM.


  •  

    Posting Permissions

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