Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

.htaccess Redirect problem

Go to End

10 Posts   3058 Views


4 November 2009 at 10:25pm Community Member, 180 Posts


i have multi language site (PL,DE) and two domains

domain A should be the main domain of PL version
domain B should redirect to german main page

so in htaccess i put

RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$ [R=301,L]

and it works but only when domain doesn't start with "www"

i put another rule

RewriteCond %{HTTP_HOST} ^ [OR]
RewriteCond %{HTTP_HOST}
RewriteRule (.*)$ [R=301,L]

but now nothing works
there is some problem with this rule: RewriteCond %{HTTP_HOST}
always get an error
"Moved Permanently The document has moved here."

and another question
why when i have: RewriteCond %{HTTP_HOST} ^
and enter the site i get a ?url=/de at the end of the URL ?


5 November 2009 at 6:48pm Community Member, 283 Posts

You have to evaluate rewrites in priority, and this case make the www optional.


5 November 2009 at 9:07pm Community Member, 180 Posts


RewriteCond %{HTTP_HOST} !^www\
RewriteRule (.*)$ [R=301,L] => redirect to DE main page GOOD => redirect to PL main page BAD


6 November 2009 at 5:03am Community Member, 283 Posts

Sorry I was posting last night when I should have been sleeping, what I wrote wasn't useful at all.

So to do the optional www, I don't think using ! (nots) for negative matching is the best approach. Maybe something like this

RewriteCond %{HTTP_HOST} ^.*domain\.de$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

I didn't test that, so let me know if it works.

The ?url=/de part is something I've run into quite often with SS. The short answer is append a / to the end and it will go away, like

It has to do with some wonky matching and necessary voodoo in the HTTPResponse. Well that is my opinion as I understand the code that is.


6 November 2009 at 8:13am Community Member, 180 Posts

thanks for helping but still nothing
now both of domains get 301 ERROR

is it possible to redirect to and than to ? maybe it is stupid way but i dont have any idea :(


6 November 2009 at 8:32am Community Member, 283 Posts

That would be the R=301 at work, remove it so that it is just [L] if it is the last rule. You might have to get comfy with other tutorials and man pages for mod_rewrite:


6 November 2009 at 9:37pm Community Member, 180 Posts

i tried to do the same by PHP

   function redirect() {
      $adress = 'http://'. $_SERVER['HTTP_HOST'];

      if($adress == '') {

but i get error 301 too !!

i do not understad what the **** is going on :/


7 November 2009 at 6:59am Community Member, 283 Posts

Sorry but this is beyond my RewriteEngine On skills. You might try on IRC or in another apache forum where there are experts better suited to help you out.

Go to Top