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

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
brans

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

Post 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?
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

I would really love the same.....
http://www.studmed.dk Portal for doctors and medical students in Denmark
Jimmy_Jazz
Posts: 23
Joined: Thu 28. Oct 2004, 13:04
Location: London

Post 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
brans

Post 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 ?
Jimmy_Jazz
Posts: 23
Joined: Thu 28. Oct 2004, 13:04
Location: London

Post 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....
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post 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
http://www.studmed.dk Portal for doctors and medical students in Denmark
brans

Post 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
?>
brans

Post 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
Post Reply