V-K
V-K

Reputation: 1347

Htaccess: redirect some pages from one domen to another

I need to redirect some pages from one domen to another. Example: example.com/help/questions(/show/some_text|none|get params) to example2.com/questions(/show/some_text|none|get params)

htaccess:

Redirect permanent /help/questions    http://example2.com/questions

But redirect from example.com/help/questions/show/some_text doesn't work - I have example2.com/help/questions/show/some_text instead example2.com/questions/show/some_text With such code I have some problem.

RewriteCond %{HTTP_HOST} example.com/help/questions
RewriteRule (.*) http://example2.com/questions/$1 [R=301,L]

How I can fix it? All another pages redirect normally.

Upvotes: 2

Views: 46

Answers (2)

anubhava
anubhava

Reputation: 785316

%{HTTP_HOST} only matches host name not URI.

You can use:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC]
RewriteRule ^help/(questions/.*) http://example2.com/$1 [R=301,L,NC,NE]

Upvotes: 1

himeshc_IB
himeshc_IB

Reputation: 863

  1. Make sure you have set "AllowOverride All" in httpd.conf or apache.conf.
  2. Make sure you have rewrite_module, headers_module, and alias_module apache modules enabled.

Upvotes: 0

Related Questions