Redirect to subdomain not working

Hi guys, I've a got a domain.com and a subdomain.domain.com

I want that users going to www.domain.com and domain.com get redirected to subdomain.domain.com.

Right now I'm using this in the .htaccess

RedirectMatch 301 ^(.*)$ / http://subdomain.domain.com/$1

But it doesn't work. Any idea?

Thank you in advance

3 Replies

We'll need to know what software you use for your web server (apache, nginx, etc) to give you a proper url rewrite rule.

Another possibility is to place an index.html in the web root for domain.com that contains the following code (adjust as necessary):

<title>Your Page Title</title>

Optional page text here.

This is basically just an html redirect, so when someone visits domain.com and their browser loads index.html, it will see the tag telling it to "refresh to url", or in other words, to redirect to another url.

Yeah sorry, I forgot to mention that I use apache

I'm not familiar with url rewrites in apache, but as far as I can tell from Google, you need to have the following line inserted into .htaccess before you define any rewrites/redirects:

RewriteEngine on

Then below this, you may define your rewrites/redirects.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct