Pergunta

I'm trying to redirect traffic that attempts to access:
cat.rs.allgames.com/cloud/11/services/titles/game5/console/file.json

to:
cat.cloud.allgames.com/titles/game5/console/file.json

using a 301 permanent redirect in an .htaccess file, but it always sends me to:
cat.cloud.allgames.comcloud/titles/game5/console/cloud/11/services/titles/game5/console/file.json

which is nowhere near correct. What am I doing wrong?

My .htaccess is located in:
cat.rs.allgames.com/cloud/11/services/titles/game5/console/file.json

and looks like this:
Redirect 301 / http://cat.cloud.allgames.com

Foi útil?

Solução

The Rewrite module should do what you want! You need to make sure the rewrite module is enabled (for ubuntu: sudo a2enmod rewrite), then add this to your .htaccess file.

RewriteEngine On
RewriteRule ^/cloud/11/services/titles/(.*)$ http://cat.cloud.allgames.com/titles/$1 [R=301]

Here, the ^/cloud/11/services/titles/(.*)$ catches anything after the titles part of the URL. Then the $1 at the end of the second part attaches what we caught to the end of the new URL. Finally, you can specify it as an external 301 rewrite to another server with the [R=301] flag!

Hope that works for you!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top