A
A
Alexey2013-11-13 23:24:44
htaccess
Alexey, 2013-11-13 23:24:44

Redirecting from subdomain to domain using .htaccess

Hello! Please tell me how you can redirect from a subdomain to the main domain using .htaccess. There is a subdomain1.mysite.com subdomain, you need to transfer the user from this subdomain to mysite.com/index.php?action=1 but the subdomen1 address should remain in the address bar. mysite.com.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
P
Pavel Voronyuk, 2013-11-13
@pawlek

Redirect http://subdomen1.mysite.com http://mysite.com/index.php?action=1 RewriteEngine on RewriteBase / RewriteRule ^ http://subdomen1.mysite.com$ http://mysite.com/index .php?action=1

A
Alexey, 2013-11-13
@kerner

Unfortunately, this method does not work. Mod Rewrite redirects to the main page of mysite.com

P
Par Mactep, 2013-11-14
@parmactep

Isn't it easier to make a subdomain an alias of the main domain?

A
Alexey, 2013-11-14
@kerner

I would be very grateful if you tell me how best to do this in order to fulfill all the conditions set

M
Masterme, 2013-11-14
@Masterme

you need to get into the apache config and for your virtual host do this <virtualhost> ServerName domain.com ServerAlias ​​subdomain.domain.com # ... </virtualhost>

hosting usually has such an option - site aliases. for example, you create domain.com, you are asked for aliases, the most common is www.domain.com. add one or more to it. by the way, www is just a subdomain

A
Alexey, 2013-11-14
@kerner

The site is on shared hosting and there is no way to access Apache configs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question