Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite for regional websites

mod_rewrite for regional websites. none for default

         

Mark Williams

10:55 am on Aug 15, 2006 (gmt 0)

10+ Year Member



Hi, I have used mod_rewrite a couple of times before, but I can't figure out how to use it for my current problem.

I have four regional sites (England, Northern Ireland, Scotland and Wales, each site resides in a subdirectory in the root diretory of the site (/en,/sc,/wa,/ni). By default the site that users will see will be the English site accessed by www.example.com/, or www.example.com/directory/page.jsp and these pages neeed to be served from the /en/ directory. However, if a user switches to a regional site, Scotland for example, the URLs they will use will be www.example.com/sc/ or www.example.com/sc/directory/page.jsp so I don't think that the mod_rewrite need appply to these.

I need some kind of exclusion clause for /sc/,/wa/,/ni/ folders and redirect to /en/ for / requests but I can't for the life of me figure out what exactly I need.

Can anyone help please?

Thanks,

Mark

jdMorgan

1:06 pm on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first part is probably easy -- Use RewriteCond to examine the REQUEST_URI, and exclude requests for the /sc/, /wa/, and /ni/ subdirectories:

RewriteCond %{REQUEST_URI} !^/(sc¦wa¦nl)/

You'll have to describe what you want to do with "/" requests in more detail, though, and I suggest you address one problem at a time in these forums so as to avoid major confusion.

Note that posting on this forum modifies the pipe characters used above - Change all broken pipe "¦" characters to solid pipes before use.

Jim

[edited by: jdMorgan at 1:06 pm (utc) on Aug. 15, 2006]

Mark Williams

4:05 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



Thanks jd.

Now for the "/" bit. Requests made to this URL will be for English pages so all these requests will need to retrieve content from the "/en/" folder in the root of the site but not actually redirect the user's browser to /en/. This redirect of requests will need to be done for all requests made to /, so www.example.com/index.jsp will redirect to www.example.com/en/index.jsp, www.example.com/a_folder/a_page.jsp will redirect to www.example.com/en/a_folder/a_page.jsp etc.

Thanks

[edited by: Mark_Williams at 4:28 pm (utc) on Aug. 15, 2006]

jdMorgan

11:34 pm on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't really know what you mean by a "/" request. The only working definition I can imagine is that you mean "a request for a local-URL-path not starting with /sc or /wa or /nl."

If that's the case, simply rewrite all remaining URLs that do not start with those or with "/en" to the same local URL-path, but with "/en" prepended.


RewriteCond %{REQUEST_URI} !^/(sc¦wa¦nl¦[b]en[/b])/
RewriteRule (.*) /en/$1 [L]

(Best guess based on sketchy description).

Note that posting on this forum modifies the pipe characters used above - Change all broken pipe "¦" characters to solid pipes before use.

Jim