Results 1 to 26 of 26

Thread: Directories that don't actually exist

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Directories that don't actually exist

    I'm wondering how do you use PHP to make it look like there are directories that don't even exist.

    I can't point to specific websites but I've worked on existing code (didn't have a chance to look at the code that did this function) where there are pages that look like www.mydomain.com/products/inside/Model# but only the products directory existed. There was not inside directory.

    How do you do this? Does it require special configuration via apache or can it be done in only php?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    This is acheieved in the server configuration . If you are using Apache you can use the URL Rewriter to morph the URLS.

    http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

    This will work in .htaccess files provided your host has enabled the feature.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Directories that don't actually exist

    Thanks, I'll have to look further into that (though I could have sworn I didn't see any .htaccess files =/)
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    It can also be put in the main server configuration file httpd.conf.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Directories that don't actually exist

    Thanks.

    I've been reading through the guide but am not really understanding how to adopt this for my situation.

    Like, say I have a url that looks like this: www.binaryidiot.com/?area=software&product=perspective. How can I make it so the area and product get variables are still get correctly but the URL is shown as www.binaryidiot.com/software/perspective?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  6. #6

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Directories that don't actually exist

    Anyone have any examples for the types of URLs I'm looking to create?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Directories that don't actually exist


  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    I thouhgt I had replied to this. Obviously not In your .htaccess file or directory container inside the httpd.conf file you could have the following:
    Code:
    RewriteEngine on
    RewriteRule ^/products/inside/Model_([0-9]+)/ /products/inside/model.php?model=$1
    You may also want to set the ReqriteBase to the directory you are working with.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Directories that don't actually exist

    Quote Originally Posted by penagate
    Thanks. It helped my understand but I am still having issues (do'h!).

    I wanted to just test this with my current website which has URLs formatted like this:
    Code:
    http://www.binaryidiot.com/index.php?area=news&id=68
    So my goal was to make them look like this:
    Code:
    http://www.binaryidiot.com/article/68/
    So I basically copied and pasted the code from the website and just replaced a few parts with my website's information. Simple enough, right?
    Code:
    RewriteRule ^article/(.*)/$ index.php?area=news&id=$1
    Doesn't work.

    Quote Originally Posted by visualAd
    I thouhgt I had replied to this
    Oh you did. I'm just dumb sometimes ()

    After seeing visualAd's code I tried this:
    Code:
    RewriteEngine On
    RewriteRule ^article/(.*)/$ index.php?area=news&id=$1
    Still no go.

    I then tried to modify visualAd's code because it had more slashes and ended up with something like this:
    Code:
    RewriteEngine on
    RewriteBase /
    RewriteRule ^/article/(.*)/ /index.php?area=news&id=$1
    Still no go. I tested it on my current webserver as well as an internal apache server I have setup. Both looks like they're setup correctly. All of this is going into a .htaccess file as well in the same directory as index.php (I noticed in 1 of the articles it said to put it in the directory before the htdocs and I tried that as well with no luck).

    So... what am I doing that's so wrong?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  10. #10
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    Have you ensured that mod rewrite has been orverriden in the httpd.conf file?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  11. #11

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Directories that don't actually exist

    Quote Originally Posted by visualAd
    Have you ensured that mod rewrite has been orverriden in the httpd.conf file?
    I've searched all over the place. It looks like it's enabled on both my local server and my remote server but I still can't get anything working.

    What do you mean by has it been overridden? I couldn't find anything on override mod rewrite.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  12. #12
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    In the main server configuration file for thee document root directory container, you need to have an AllowOverride driective. This allows directives to be overriden in the .htaccess files.
    Code:
    DocumentRoot /var/www
    
    <Directory /var/www>
        AllowOverride Indexes FileInfo
    </Directory>
    FileInfo includes the mod_rewrite directives.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  13. #13
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: Directories that don't actually exist

    visualAd please explain more is the phrase FileInfo supposed to be replaced with the filename?
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

  14. #14
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    No, you put this in the httpd.conf file for the directory that you want to allow .htaccess files to be able to use mod_rewrite in.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  15. #15
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: Directories that don't actually exist

    after doin all thats been said, i still get the object not found error.
    pls help
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

  16. #16
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    What does your httpd.conf file and .htaccess file look like? - could you upload them?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  17. #17

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Angry Re: Directories that don't actually exist

    I think I offically give up, lol. Still can't get anything to work. I thought it would be a simple .htaccess file or something but it doesn't work on my local server or remote server. Bah!

    Here is my .htaccess:
    PHP Code:
    RewriteEngine on
    RewriteBase 
    /v4/
    RewriteRule ^/v4/Article/(.*)/ /index.php?area=news&id=$
    I am putting that in the same directory as my index.php file (which resides in localhost/v4/). I tried changing it around like I mentioned before.

    Attached is my httpd.conf file but I only changed the 1 thing you said (everything else is default). Though I saw you mention that the httpd.conf should go in the directory that you want the morph the DLLs. I thought it was supposed to go into only the conf directory.
    Attached Files Attached Files
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  18. #18
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    Are you using user_dir directories i.e:

    http://localhost/~username/v4/Article/5/

    As fielinfo is only enabled for these.

    Also, you need not use rewritebase in a .htaccess, as it is always relative to the directory which the .htaccess file is in:
    Code:
    RewriteEngine on
    RewriteRule ^v4/Article/(.*)/ index.php?area=news&id=$1
    Notice also how I've removed the forward slashes at the front to make it relative.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  19. #19

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Directories that don't actually exist

    Quote Originally Posted by visualAd
    Are you using user_dir directories i.e:

    http://localhost/~username/v4/Article/5/

    As fielinfo is only enabled for these.
    I am not using user_dir directories. It's just http://localhost/v4/Article/5. My remote server has this enabled though so maybe I'll try that again.

    Is there anyway to make it work without user_dir?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  20. #20
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    Quote Originally Posted by kasracer
    I am not using user_dir directories. It's just http://localhost/v4/Article/5. My remote server has this enabled though so maybe I'll try that again.

    Is there anyway to make it work without user_dir?
    You need also to enable FileInfo in the document root directory container too. URL rewriting is only cconerned with the URL, the location of the file on the server is irrelevant.

    At present your entire document root directory container is commented out. Therefore, Apache will ignore it:
    Code:
    #<Directory "E:/apache/htdocs"> <---- a # at the beginning of a line makes it a comment.
    #</Directory>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  21. #21

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Directories that don't actually exist

    Thanks for all your help visualAd. I think I may agree with apache's docs about mod_rewrite
    With mod_rewrite you either shoot yourself in the foot the first time and never use it again or love it for the rest of your life because of its power. This paper tries to give you a few initial success events to avoid the first case by presenting already invented solutions to you.
    I don't know why I still can't get it to work, lol. Honestly, I wanted a solution that I could just include in my .htaccess or something that way I could easily drop my website onto another server because I will most likely be changing servers sometime this year and possibly again next year. If I have to attempt to configure apache everytime (something I don't even have access to via my shared hosting right now), this solution probably won't work the way I want. I was hoping for something that would either turn a neat looking URL into something my PHP scripts could use like normal or maybe a way to use a php file to process all my URLs (like no matter where you go on my site, the URL is sent to 1 PHP script to determine where to put you).

    Thanks again though. I'll keep trying for a little while longer heh
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  22. #22
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Directories that don't actually exist

    Did you make the changes I suggested above? It will work if you make them.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  23. #23

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Directories that don't actually exist

    Quote Originally Posted by visualAd
    Did you make the changes I suggested above? It will work if you make them.
    Yeah it still didn't work. The odd thing is, Apache's service died about an hour or so after making the changes and I couldn't restart it. Attempting to restart the computer also did nothing so I had to unisntall it; lol. I'll reinstall and try again later. I also will e-mail my host to see if my remote server supports this.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  24. #24
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Directories that don't actually exist

    Well I had cause to try this out myself today and I am happy to announce the RewriteRule works fine.


  25. #25
    New Member v!sualAd's Avatar
    Join Date
    Oct 2004
    Location
    Pasta factory
    Posts
    6

    Re: Directories that don't actually exist

    I have never had any problems too. When you reinstall, upload your httpd.conf again. I am quite sure you have a missconfiguration.
    I love pasta

  26. #26
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: Directories that don't actually exist

    Quote Originally Posted by v!sualAd
    Code:
    DocumentRoot /var/www
    
    <Directory /var/www>
        AllowOverride Indexes FileInfo
    </Directory>
    i finally got it to work!!!
    i got it to work about 3 days ago but i couldn't get to forum then

    but i used All instead of Indexes FileInfo


    thanks visual
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

Posting Permissions

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



Click Here to Expand Forum to Full Width