How do you get URLs like below when using php? http://domain.com/photos/022010/01/ Where it normally is written like this: http://domain.com/photos.php?date=022010&id=01 I see sites like this all the time now and am curious how this is accomplished. I do have an idea though... When creating a directory for example photos. Do I just put an index.php file in that directory and just in my php instead of calling on a href as "?date=.$row['date']." do I call it as "/.$row['date']./" ? Hope that is explained well. I guess twitter would be an example of what I am talking about. I just cannot recall the url where I specifically saw this. If someone does know what I am talking about can they please shed some more light on it? Thanks!
Hi Phil, I can give you a clue. It doesn't relate with PHP. It has something to do with mod_rewrite and .htaccess. You can find this clean url method by googling.
Mod rewrite is a very easy to use Apache module which uses regular expressions to find matches and replaces them as a redirect. A basic one would be something like this, RewriteEngine On RewriteRule ^([^.]+).html /index.php?page=$1 Code (markup): Say we had a index file which was loading the content via index.php?page=home, now we could have it look like home.html but it's really index.php?page=home It's not actually like that it's the beauty of mod rewrite, just from that example that will get you started. Kind regards, Glen Hughes
Yes. Your answer is .htaccess . Be sure that your server have the mod_rewrite enabled to use .htaccess . Good Luck .