skip to Main Content

I have a conditions:
a) Redirect from help.example.com to example.com/support
b) Redirect from other page, like help.example.com/catalog to example.com/catalog

This all I do in .htaccess file.
My code redirect me only on example.com/support

RewriteCond %{HTTP_HOST}${REQUEST_URI} ^help.example.com/(.+)
RewriteRule ^(.+)$ example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST}${REQUEST_URI} ^help.example.com
RewriteRule ^(.*)$ example.com/support/ [R=301,L]

How can I resolve this problem?

2

Answers


  1. With your shown samples/attempts, please try following htacces rules in your htaccess file. Please place these rules at top of your file, also make sure to clear your browser cache before testing your URLs.

    This will catch help.example.com OR www.help.example.com both kind of urls.

    RewriteEngine ON
    RewriteCond %{HTTP_HOST} ^(?:www.)?help.example.com$ [NC]
    RewriteRule ^/?$ https://example.com/support [NE,R=301,L]
    
    Login or Signup to reply.
  2. Please try this rules for yours a – b conditions:

    a) Redirect from help.example.com to example.com/support

    RewriteCond %{HTTP_HOST} ^help.example.com$ [NC]
    RewriteRule ^(/?)$ https://example.com/support [R=301,L]
    

    b) Redirect from other page, like help.example.com/catalog to example.com/catalog

    RewriteCond %{HTTP_HOST} ^help.example.com$ [NC]
    RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search