Forum Moderators: phranque

Message Too Old, No Replies

yet another mod_rewrite thread

can i do this dynamically?

         

jungle brother

12:09 pm on Nov 26, 2003 (gmt 0)

10+ Year Member



i have a tutorial site and at the moment the urls look like this:

www.mysite.com/tutorials.php?id=$tut&page=$page
eg. www.mysite.com/tutorials.php?id=123&page=1

i've heard i can rewrite this to:

www.mysite.com/tutorials/$tut/$page.html
eg. www.mysite.com/tutorials/123/1.html

for search engines and spiders and whatnot, but it appears i can only do this manually.....is there a way to do this automatically, basically i want people to be able to submit a tutorial, and straight away for it to be available at the 'rewritten' address, can i do this in the subnmission script? its really not feasable to do it manually.

oh btw, theres not always a fixed number of variables in the query, is it possible to, maybe, step back through the url and assign variables as it goes? so on:

www.mysite.com/food/cheese/biscuits/bread.html

it'd assign variables to end up with

$var1 = food
$var2 = biscuits
$var3 = bread

thankyou for any help anyone can give, im new to all this rewriting stuff

dcrombie

1:20 pm on Nov 26, 2003 (gmt 0)



All of that can be done using mod_rewrite - check the Apache forum for examples. The process involved defining "rules" using "regular expressions". Depending on what your variables are, a number of rules could handle different numbers of variables.

Tip: start simple - you probably only need one rule to open your site up to search engines.

;)

jatar_k

5:29 pm on Nov 26, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



This is a good thread to start out with, there are many good links in there as well.
An Introduction to Redirecting URLs on an Apache Server [webmasterworld.com]

You can also take a look through some of the othe threads in this particular forum there are many examples as dcrombie mentioned.