Forum Moderators: coopster

Message Too Old, No Replies

URL Problem

Need suggestions on how to structure a website

         

Sekka

8:43 am on Apr 3, 2006 (gmt 0)

10+ Year Member



Hi.

I currently make websites so that every section is included into my index.php via an id number,

e.g. the URL often ends up www.someurl.co.uk/index.php?id=491

I am wanting to do a more user friendly URL approach. For example, I want to give the impression of a structured website using folders etc, but they will be the same page just with different content, e.g.

www.someurl.co.uk/page1/
www.someurl.co.uk/page7/subpage53/

What is the best way to do this without putting my website files within EVERY folder, or is there a way to achieve this without making the folders at all?

Thank you.

scriptmasterdel

9:25 am on Apr 3, 2006 (gmt 0)

10+ Year Member



You can achieve this by using a .htaccess file with Rewrite Conditions!

Then run every link through your index.php file ;)

Want an example? ... Then let me know!

Del

Sekka

10:35 am on Apr 3, 2006 (gmt 0)

10+ Year Member



Wouldn't mind one, please! :D

omoutop

10:41 am on Apr 3, 2006 (gmt 0)

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



in your .htaccess file write something like this:

Options +FollowSymLinks
RewriteEngine on
RewriteOptions inherit

RewriteRule ^([^/]+)/([^/]+)/([^-]+)-([^-]+)\.htm$ my_page.php?var1=$1&var2=$2&var3=$3&var4=$4 [NC,L]

The above pattern will lead you from [mysite.com...] form to something like [mysite.com...]

For more info on using htaccess mod_rewrite check [webmasterworld.com...]

Sekka

11:43 am on Apr 3, 2006 (gmt 0)

10+ Year Member



This helps a lot. Thank you.