Question

I am running a dokuwiki under http://blabla.com/ and now I have the additional url http://wiki.com/

What I want is to redirect users who request http://blabla.com/test/gna or anything else to http://wiki.com/test/gna without harmin the default .htaccess of dokuwiki

<Files ~ "^([\._]ht|README$|VERSION$|COPYING$)">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>

RewriteEngine on

RewriteBase /dev/

RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L]
RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L]
RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L]
RewriteRule ^$                        doku.php  [L]
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
RewriteRule ^index.php$               doku.php

Just adding something like this at the end or beginning does not have any effect at all:

Rewritecond %{HTTP_HOST} !blabla.com/
RewriteRule ^/(.*)$ http://wiki.com/$1 [L,R=301]
Was it helpful?

Solution

Try removing the leading slash, apache removes it when passing URI's through rewrite rules in htaccess files:

Rewritecond %{HTTP_HOST} blabla.com
RewriteRule ^(.*)$ http://wiki.com/$1 [L,R=301]

Though you probably want to add it above your other rules so the redirected target doesn't have the doku.php?id=stuff in the URL.

OTHER TIPS

Try using the below lines:

# Any URL from blabla.com will be redirected to corresponding URL on wiki.com
Rewritecond %{HTTP_HOST} ^blabla.com$
RewriteRule ^(.*)$ http://wiki.com/$1 [L,R=301]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top