1

hello i have the following problem regarding mod_rewrite:

i have build a page that is called example.php

now i'm still searching for a rewriterule for the following issue:

because of different languages but the same content of the page example.php i would like to have a rewriterule when an user is entering for example site.com/beispiel.php

what will be the same word for example in german. so there is only one page. but the imaginary url site.com/beispiel.php would be the same content.

so if there is someone who knows how to solve this problem i really would appreciate. thanks a lot.

bonny
  • 3,147
  • 11
  • 41
  • 61

2 Answers2

0

I was thinking about it :

If you use the google translator as shown in translate a PHP $string using google translator API

Then redirect from PHP to

www.yoursite.com/translate.php?translated_language=keyword_from_script

Then use a mod_rewrite from the last answer with that parameter, it should work?

Community
  • 1
  • 1
mlishn
  • 1,689
  • 14
  • 19
  • okay, translation should not be the problem. i also could create a table on my db. the problem is the redirection using mod_rewrite. i have 'RewriteRule ^beispiel$ /example' that does not work – bonny Jul 24 '12 at 15:03
  • Create a set of 301 redirects to example.php – mlishn Jul 24 '12 at 15:10
0

Redirections and internal redirections are two different things.

An HTTP Redirection with a code 302 or 301 imply several HTTP request and the user will see at the end that he has been redirected to /example.php. An internal redirection means serving one file B on the server for a file A requested, without the user knowing it.

Internal Redirection does not need mod-rewrite's rules. The Alias and AliasMatch directives could be used to map some requested files to a real file.

Alias /beispiel.php /path/to/my/docroot/example.php

External Redirection could also be performed without mod_rewrite, by using Redirect and RedirectMatch directives.

Now you could also use mod_rewrite to perform these two types of redirections (internal & external).

# internal alias
RewriteRule ^beispiel.php$ /path/to/my/docroot/example.php [L]
# Or external redirection, with a R tag
RewriteRule ^beispiel.php$ example.php [L, NC, R=302]

With external redirections qlways Start by trying some rewriteRiles handling 302 redirections. When it will be working you could use 301 redirects as the browser store 301 results and do not ask anymore before restart.

If you have a big number of rediirection to perform and you are not stuck with .htaccess files (i.e. you can edit the real apache configuration files), you could have a look at RewriteMap to speed-up your rewriteRules.

regilero
  • 29,806
  • 6
  • 60
  • 99