A Digital Age Deserves A Digital Leader

questions about 'clean url's' with PHP and apache 2

questions about 'clean url's' with PHP and apache 2

Postby l33t » Wed May 02, 2007 4:54 am

as i learn more and more about PHP, ive decided to give myself more practice with PHP by redoing my entire website with clean URLs (among many other changes)

my questions are this:
1) what is the best way to do this, assuming i want to achieve an affect like this (http://site.com/argument1/argument2/arg ... hepattern/)
should i jsut get the global URL variable and then explode it by '/' or is there another, better way to do this?

2) as you can imagine, a url like this (site.com/argument1/arg2/) will create problems because the webserver will actually look for a folder (within the web root) called argument1. i do not want this to happen... i want *all* requests to be sent to ONE file (the index.php) that sits in my webroot. i assume this can be done with a glabal mod_rewrite rule... but i am unsure as how to best accomplish this... any hints/ideas/examples you can point me to?

EDIT:
this is just a genral question, and i dont think it warrens its own thread.
How can i prevent a browser from viewing the contense of a directory, but still allow it to access the directory for any files it may need. EG: my login page is served from its own directory, but it also has a few included 'minipages' that must be in the same directory as well as some images... as of now, it is possible to view the contense of the directory that is serving the login page; this meaning that the user can see the login.php as well as the other 'included' pages and the images that are used by the login.php. how can i make it so that the users browser can access the images, but not do a directory view? i am sure its possible (probably useing a .htaccess file, am i right?) but i do not know how to do this so if you could show me a tutorial or site devoted to such things (a specific apache configuration forum perhaps...?) i would greatly appreciate it!
thanks for your time.
PRO Level 14
User avatar
Posts: 882
Joined: Mon May 02, 2005 2:06 am

Postby imnuts » Wed May 02, 2007 11:16 pm

All you need to know is in the Apache Manual. It's relatively the same between version 2.0 and 2.2 for some of the stuff. The 2.2 manual is here and the 2.0 manual is here. To answer your first question, you'll need mod_rewrite (or something similarly named) and you put the re-write rules into a .htaccess file and it should take the given URL with the '?' and '&' and whatever else you want and turn it into the url with the '/' in it. As for the other part (your edit) you want to look for the instructions about adding info to .htaccess for directory listings as you can have it omit entries and change the font/styling/etc. on the directory listings.
Image
PRO SUPREME
User avatar
Posts: 7457
Joined: Wed Mar 24, 2004 5:19 am
Location: Boothwyn, Pennsylvania
Real Name: Mark

Postby l33t » Wed May 02, 2007 11:27 pm

imnuts wrote:All you need to know is in the Apache Manual. It's relatively the same between version 2.0 and 2.2 for some of the stuff. The 2.2 manual is here and the 2.0 manual is here. To answer your first question, you'll need mod_rewrite (or something similarly named) and you put the re-write rules into a .htaccess file and it should take the given URL with the '?' and '&' and whatever else you want and turn it into the url with the '/' in it. As for the other part (your edit) you want to look for the instructions about adding info to .htaccess for directory listings as you can have it omit entries and change the font/styling/etc. on the directory listings.


thanks for the links to the manual... sometimes i wonder how i actually miss things like that.

ill look through there (in addition to my constant googeling) and ill post back if i need anything else.
PRO Level 14
User avatar
Posts: 882
Joined: Mon May 02, 2005 2:06 am

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 2 guests

cron
cron