Page 1 of 1

mod_rewrite rule for index.php?deutsch&lang=deutsch&

Posted: Thu 16. Dec 2004, 13:52
by brans
Hi ppl,

I need the apache rewrite rule to turn this:

mydomain.com/index.php?aboutme&lang=deutsch&empl=mm

to:

mydomain.com/deutsch/mm/aboutme.phtml

is this possible and if yes, could anyone give me the fitting rewrite rule or some more information were I can find tutorials on this topic?

Posted: Thu 16. Dec 2004, 19:18
by frold
I would really love the same.....

Posted: Fri 17. Dec 2004, 13:25
by Jimmy_Jazz
use the alias function.

type in the alias field :

deutsch/mm/aboutme

You will need to add this code to the <head> of your template:

<base href="http://www.yourdomainhere.com/">

You need this base ref or the cms will try and find all your images etc in the mm folder (which doesnt exist!). I think you can do that with the htaccess file but not sure....

If anyone has a better way please share :D

Posted: Fri 17. Dec 2004, 14:24
by brans
Ouhm sorry but i totally don't understand what the alias function should be ? this doesn't work cuz how can I then define my variables ?

Posted: Fri 17. Dec 2004, 15:10
by Jimmy_Jazz
Maybe i misunderstood you?

I thought you just wanted to have your friendly urls look like they are in directories ie

http://www.directories.com/like/this/index.phtml

sorry if this is not what you were after....

Posted: Sat 18. Dec 2004, 10:52
by frold
Jimmy_Jazz wrote:Maybe i misunderstood you?

I thought you just wanted to have your friendly urls look like they are in directories ie

http://www.directories.com/like/this/index.phtml

sorry if this is not what you were after....
Thats what I would like....

http://www.mysite.com/levelname/sublevelname/page.phtml

Like

http://www.mysite.com/products/computers/laptop.phtml

Posted: Sat 18. Dec 2004, 12:13
by brans
yes me too... this is absolutely possible through the alias function!

so if you have a site structure like this:

home
- page 1
-- page 1.1
-- page 1.2
- english 2
-- page 2.1
--- page 2.1.1

simply name the aliases of the pages like this:

alias of home is:
/home/
alias of page 1 is:
/home/page1/
alias of page 1.1 is:
/home/page1/page1.1/
and so on...

alias of page 2.1.1:
/home/page2/page2.1/page2.1.1/

thats very easy to realize but my problem was anotherone!

I use redirection to define the variables for each category:

so for example if my page looks like this:

- german
-- firma
- french
-- entreprise
- english
-- company

then for example my redirection for german looks like this:
index.php?german&lang=german&empl=mweber

where lang is the language of my navigation (can't use a dynamic one in my template so I define it through an external, hardcoded template) and
empl is employee because for each article I want to have the possibility to define someone who is responsible for this section and thus load his / her contact information from another external, hardcoded template.

I guess that now you can see why I need to use the mod_rewrite function and can't count on the alias function or does anybody know a way to handle the following:

if my page alias was the following (systematic is as described above):

/home/mweber/german/product/

could I then read the information out of this string by php
(could I create a function that would turn this string into the following ?
<?php
lang=german
empl=mweber
?>

Posted: Sat 18. Dec 2004, 13:29
by brans
ok I did it ;-)

Code: Select all

RewriteRule ^([a-z]+)_?([a-z]+)?_?([a-z]+)?\.html$ index.php?$2&lang=$3&empl=$1 [L]
I had to use a little trick:

Example:

my category alias is:
company

then I forward this category to:
mweber_company_deutsch.phtml to make apache redirect this url to:

index.php?company&lang=deutsch&empl=mweber

I recommend you to use at maximum one subdirectory !

I don't use any because otherwise you have to reorganize all your templates and paths to images etc. because wcms will for example try to load your stylesheets from:

yourvirtualsubdir/include/inc_css/frontend.css