472,982 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

"Pseudo directory" urls

Hey.

I've got a very basic newbie question, I hope you can understand me.
Sorry for asking it, first of all.

I see a lot of sites (e.g. communities) with a url-structure like
this: example.com/users/paul (displaying the user profile of "paul")
or example.com/pictures/landscapes/13 (displaying pictures from the
category "landscapes", page 13). These are just examples, I hope I
didn't confuse you.

Well, in my sites I call sites with GET parameters. For example:
myexample.com/index.php?site=users&user=paul or myexample.com/
index.php?site=pictures&cat=landscapes&page=13. In my index.php file I
check for those parameters and include the relevant php file.

For me, my method somehow looks unprofessional compared to those
"pseudo urls" described at the beginning. I'm calling them pseudo urls/
directories, because I don't think there is a physical directory for
every user, for example. If a website has over 10.000 users, I don't
think they have a directory for every single user, so I guess there's
another way to get those nice-looking structure.

How to do that?

Thanks in advance.
Feb 4 '08 #1
4 3209
..oO(k3pp0)
>I've got a very basic newbie question, I hope you can understand me.
Sorry for asking it, first of all.

I see a lot of sites (e.g. communities) with a url-structure like
this: example.com/users/paul (displaying the user profile of "paul")
or example.com/pictures/landscapes/13 (displaying pictures from the
category "landscapes", page 13). These are just examples, I hope I
didn't confuse you.

Well, in my sites I call sites with GET parameters. For example:
myexample.com/index.php?site=users&user=paul or myexample.com/
index.php?site=pictures&cat=landscapes&page=13. In my index.php file I
check for those parameters and include the relevant php file.

For me, my method somehow looks unprofessional compared to those
"pseudo urls" described at the beginning. I'm calling them pseudo urls/
directories, because I don't think there is a physical directory for
every user, for example. If a website has over 10.000 users, I don't
think they have a directory for every single user, so I guess there's
another way to get those nice-looking structure.

How to do that?
The most common way to do that is called URL rewriting. On Apache
servers this can be done with the mod_rewrite module.

Apache Module mod_rewrite
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

URL Rewriting Guide
http://httpd.apache.org/docs/2.2/misc/rewriteguide.html

Another way would be to redirect all requests to the index.php and let
the script parse the request URL. This is what I do in my own framework,
because it makes it a lot easier for me to add new functions or modules
to a website without having to modify any rewrite rule in the .htaccess.

Micha
Feb 4 '08 #2
Another way would be to redirect all requests to the index.php and let
the script parse the request URL. This is what I do in my own framework,
because it makes it a lot easier for me to add new functions or modules
to a website without having to modify any rewrite rule in the .htaccess.

Micha
Thanks!
How do you do that ("redirect all requests to the index.php and let
the script parse the request URL")?
Feb 4 '08 #3
..oO(k3pp0)
>Another way would be to redirect all requests to the index.php and let
the script parse the request URL. This is what I do in my own framework,
because it makes it a lot easier for me to add new functions or modules
to a website without having to modify any rewrite rule in the .htaccess.

Thanks!
How do you do that ("redirect all requests to the index.php and let
the script parse the request URL")?
I also do it with mod_rewrite with some additional rules:

RewriteEngine On
RewriteBase /

# remove leading www. from hostname
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule (.*) http://%1/$1 [R=301,L]

# exclude static URIs from rewriting
RewriteRule ^(css|download|images|scripts)(/|$) - [L]

# redirect internally to application script
RewriteRule .* index.php [QSA]

The last rule will internally redirect all requests to my front
controller. Internally means that this only happens inside the web
server, it won't send a redirect back to the browser, so the browser's
address bar won't be affected.

The script then just takes a look at $_SERVER['REQUEST_URI']. If the
requested URI starts with "/user" for example, it would call a method to
handle such a user request, "/admin" would trigger another method for
handling an administration request and so on. It's more flexible than a
pure mod_rewrite solution, but also more complicated, though.

Micha
Feb 4 '08 #4
On Feb 4, 5:17 pm, Michael Fesser <neti...@gmx.dewrote:
.oO(k3pp0)
Another way would be to redirect all requests to the index.php and let
the script parse the request URL. This is what I do in my own framework,
because it makes it a lot easier for me to add new functions or modules
to a website without having to modify any rewrite rule in the .htaccess.
Thanks!
How do you do that ("redirect all requests to the index.php and let
the script parse the request URL")?

I also do it with mod_rewrite with some additional rules:

RewriteEngine On
RewriteBase /

# remove leading www. from hostname
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule (.*) http://%1/$1 [R=301,L]

# exclude static URIs from rewriting
RewriteRule ^(css|download|images|scripts)(/|$) - [L]

# redirect internally to application script
RewriteRule .* index.php [QSA]

The last rule will internally redirect all requests to my front
controller. Internally means that this only happens inside the web
server, it won't send a redirect back to the browser, so the browser's
address bar won't be affected.

The script then just takes a look at $_SERVER['REQUEST_URI']. If the
requested URI starts with "/user" for example, it would call a method to
handle such a user request, "/admin" would trigger another method for
handling an administration request and so on. It's more flexible than a
pure mod_rewrite solution, but also more complicated, though.

Micha
I was stuck on the same problem, but now that I've written a .htaccess
file with your example everything works fine, thanks :-)
Feb 4 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andrew E | last post by:
Hi all I've written a python program that adds orders into our order routing simulation system. It works well, and has a syntax along these lines: ./neworder --instrument NOKIA --size 23...
4
by: Ed | last post by:
Hello All, I posted earlier about a problem I was having with editing or pasting/deleting files in the "Home Directory" of my web server. I just noticed that the "Home Directory" option in the...
1
by: Krazitchek | last post by:
Hi, i check all directories on a disk but an error occurs when i try to enter in the "System Volume Information" directory. Is there a way to "jump" this directory without to check the name of...
7
by: Alex Maghen | last post by:
Hi. I had previously installed VS2005 beta 1. I carefully followed all the steps (I thought) to deinstall it and then installed beta 2. According to the documentation, the "Data" directory which...
1
by: Dave | last post by:
I am getting te following error in a ASP.Net app that is running on Win XP Pro (SP2): Server cannot access application directory 'C:\Documents and Settings\dave\My Documents\My Visual Studio...
8
by: lawrence k | last post by:
I've installed Apache 1.3.36 on my Redhat EL 3 machine. Now I'm trying to install PHP 5.1.4. I can not get the ./configure command to work. I keep getting this error: configure: error: Invalid...
3
by: jonnyblazed | last post by:
I've searched everywhere for this but I'm not sure exactly what to search for. What I am trying to do is pass a variable to a php script via the URL. However, I don't want to use the standard...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
4
by: Shelly | last post by:
I am coding a psudo-cron job into an application that I am writing. I don't have access to write a real cron job. Here is what I did: 1 - I downloaded pseudocron.php from its website...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.