Forum Moderators: phranque

Message Too Old, No Replies

Is mod rewrite the right tool here

can i use mod_rewrite to optionally append to the querystring?

         

HandyBiteSize

9:37 am on Jul 27, 2006 (gmt 0)

10+ Year Member



I have built a site the is allows the admin to create multilingual content. Currently the page is accessed via the URL like
www.domain.com/event/content.php?id=1
and alternative languages via
www.domain.com/event/content.php?id=1&lang=es

Now the client has asked for me to create other mappings so that

www.domain.com/SPANISHEVENT/content.php?id=1
defaults to the spanish version of that event.

One option I have is to link the SPANISHEVENT path to the default and inspect the request uri and set my default language appropriately, but that seems inefficent.

I'd like to know if i can use mod_rewrite (or another tool) to append the lang=? to the querystring, ideally only if a lang=? doesnt already exist in the qs.

Thanks in advance

hbs

jdMorgan

1:01 pm on Jul 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> One option I have is to link the SPANISHEVENT path to the default and inspect the request uri and set my default language appropriately, but that seems inefficent.

The process would be much the same using mod_rewrite: Inspect the URL for "SPANISHEVENT" and if present, then inspect the QUERY_STRING for "lang=xy", and if not present, append "lang=es" to any existing query string.

This could be done with one each of the RewriteRule and RewriteCond %{QUERY_STRING} directives.

However, if you are contemplating having many <COUNTRY>EVENT URLs, and if they will be temporary in nature, then using mod_rewrite might be somewhat of a maintenance nightmare, and I'd suggest an easy-to-administer database-driven approach instead.

Jim

HandyBiteSize

3:03 pm on Jul 28, 2006 (gmt 0)

10+ Year Member



thanks jim, that made me stop procrastinating and get on a build it into the sites' framework. Neater solution now as I can set the default lang from the lookup and now longer need to expose it in the query string