Forum Moderators: coopster

Message Too Old, No Replies

PHP directory structure and filename execution

         

TerryMc

12:47 pm on Oct 7, 2003 (gmt 0)

10+ Year Member



I've seen some of this at other sites, but don't know how to do it, so I was hoping someone might be able to help with a few questions

Lets say we have a directory structure like domain.com/stuff/

1. If I have a file called filename.php under the stuff directory, how could I execute "filename" under the directory "stuff" without having the PHP extension on it? I would want the url to be domain.com/stuff/filename
2. Is it possible to have something like
domain.com/stuff/filename?variable or domain.com/stuff/filename~variable
where the variable is passed to the filename.php without having the .php extension and without having variable=something?
3.Lastly, same directory of domain.com/stuff/ Would it be possible to have something like
domain.com/stuff/file1 and domain.com/stuff/file2
and have all the files in this directory only point to a different php (example - default.php, runme.php or something?)

Thanks for your help!

bcolflesh

1:18 pm on Oct 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could add this to .htaccess:

<Files page> ForceType application/x-httpd-php </Files>

More complicated scenarios with variables would need to be handles via mod_rewrite - many examples available on this site.

TerryMc

6:37 pm on Oct 7, 2003 (gmt 0)

10+ Year Member



Thanks for the tip, I made some changes to my .htaccess in my /stuff directory

ErrorDocument 404 stuff/myfile.php
ForceType application/x-httpd-php

This works now I have another question, if someone its domain.com/stuff/anyfilenotinthedirectory it will now display myfile.php, my next question is, how does this impact the search engines? If there is a link to domain/stuff/oldfile will the search engines still find it as /oldfile?

bcolflesh

6:40 pm on Oct 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Disallow /oldfile in your robots.txt file.

ergophobe

7:00 pm on Oct 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



These articles should have everything you need to know

[evolt.org ]
[evolt.org ]

[alistapart.com ]

Tom

TerryMc

12:20 pm on Oct 8, 2003 (gmt 0)

10+ Year Member



Thanks, that was exactly what I was looking for!