21294 Posts in 5734 Topics by 2602 members
| Go to End | Next > | |
| Author | Topic: | 2231 Views |
-
.htaccess Redirect problem

4 November 2009 at 10:25pm
hi
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 pageso in htaccess i put
RewriteCond %{HTTP_HOST} ^domain.de
RewriteRule (.*)$ http://www.domain.de/de [R=301,L]and it works but only when domain doesn't start with "www"
i put another rule
RewriteCond %{HTTP_HOST} ^domain.de [OR]
RewriteCond %{HTTP_HOST} www.domain.de
RewriteRule (.*)$ http://www.domain.de/de [R=301,L]but now nothing works
there is some problem with this rule: RewriteCond %{HTTP_HOST} www.domain.de
always get an error
"Moved Permanently The document has moved here."and another question
why when i have: RewriteCond %{HTTP_HOST} ^domain.de
and enter the site i get a ?url=/de at the end of the URL ?
http://www.domain.de/de?url=/de -
Re: .htaccess Redirect problem

5 November 2009 at 6:48pm
You have to evaluate rewrites in priority, and this case make the www optional.
-
Re: .htaccess Redirect problem

5 November 2009 at 9:07pm
hmm
RewriteCond %{HTTP_HOST} !^www\.domain.de
RewriteRule (.*)$ http://www.domain.de/de [R=301,L]domain.de => redirect to DE main page GOOD
www.domain.de => redirect to PL main page BAD -
Re: .htaccess Redirect problem

6 November 2009 at 5:03am
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 ^(.*)$ http://www.domain.de/de/$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 http://www.site.com/de/
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.
-
Re: .htaccess Redirect problem

6 November 2009 at 8:13am
thanks for helping but still nothing
now both of domains get 301 ERRORhmm
is it possible to redirect www.domain.de to domain.de and than to http://www.domin.de/de ? maybe it is stupid way but i dont have any idea
-
Re: .htaccess Redirect problem

6 November 2009 at 8:32am
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: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
-
Re: .htaccess Redirect problem

6 November 2009 at 9:37pm
i tried to do the same by PHP
function redirect() {
$adress = 'http://'. $_SERVER['HTTP_HOST'];if($adress == 'http://www.domain.de') {
ob_start();
header('Location: http://www.domain.de/de');
ob_end_flush();
}
}but i get error 301 too !!
i do not understad what the **** is going on :/
-
Re: .htaccess Redirect problem

7 November 2009 at 6:59am
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.
| 2231 Views | ||
| Go to Top | Next > |


