The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

php url variables vs directories

Wordpress is using directories instead of url variables.
Ex: "www.mysite.com/blog/page/2" instead of
"www.mysite.com/blog/index.php?page=2"

What is the advantage of using directories over page variables? And how do I do this myself? What should I google for?
web_dev
Saturday, March 10, 2007
 
 
This thread:

http://discuss.joelonsoftware.com/default.asp?design.4.457594

discussed this (among other things)

You can do it with real directories, or with mod_rewrite
I understand the advantage is that you have URLs that are more readable.

Hopefully someone will correct me if I'm wrong
Parisian Developer (still looking)
Saturday, March 10, 2007
 
 
I think you will find they are not directories, but rather as has been suggested, using some form of URL rewrite - so the [directory] structure is processed and fed to the backend server as [URL page variables].

The original intent, I believe, was due to search engines not indexing pages with (any) too many URL variables, etc.

I think it looks neater aesthetically too, but that's subjective at best.

mod_rewrite is the apache module

isapi_rewrite (http://www.isapirewrite.com/) is an example that works with iis.

I recently installed isapi_rewrite on my laptop, and the rule for your example would be something like:

# indicates a commen
# convert /blog/page/2
# to      /blog/index.php?page=2
RewriteRule /blog/page/(.*) /blog/index.php?page=$1 [I,L]

HTH
Aaron
Aaron DC Send private email
Sunday, March 11, 2007
 
 
Is one method better than the other? more secure or something?
web_dev
Sunday, March 11, 2007
 
 
I already answered your question, try reading my response again.

How long have you been a web_dev?

Aaron
Aaron DC Send private email
Monday, March 12, 2007
 
 
Aaron DC,

I don't think that one is subjective at all... both of these links go to the same post, which is more meaningful to you?

http://caseysoftware.com/?q=node/367 OR http://caseysoftware.com/month-of-php-bugs
KC Send private email
Monday, March 12, 2007
 
 
> The original intent, I believe, was due to search engines
> not indexing pages with (any) too many URL variables, etc.

Aaron,

Yes you have answered. I apologize. I was too concerned with security issues, so I must have looked right past your answer.

I haven't been a web developer for long. Too obvious? But I am learning as fast as I can.
web_dev
Monday, March 12, 2007
 
 
Three words ... Search Engine Optimization.
The text in the urls seems to have a good about of weight with the search engines.
anonymous_coward
Monday, March 12, 2007
 
 
You could just write a simple 404 handler that parses what's in the URI. Split on the / and you can pull the "2" out in your example URL to fetch the data if that was an ID or something.
Tim Patterson Send private email
Thursday, March 22, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz