E
E
elisav21082021-10-15 10:25:51
htaccess
elisav2108, 2021-10-15 10:25:51

How to remove part from http host?

My registration address was siteurl.com/register/user_type. now you need to redirect to subdomain.siteurl.com/register.
I have this code:

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/register/user_type$
    RewriteRule ^(.*)$ %{ENV:PROTO}://subdomain.%{HTTP_HOST}/register [R=301,L]
</IfModule>

But this only works if you follow the link siteurl.com/register/user_type. If you go to subdomain.siteurl.com/register/user_type, then the redirect is subdomain.subdomain.siteurl.com/register
How can I remove the subdomain first. to leave subdomain.siteurl.com/register

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wisgest, 2021-10-15
@wisgest

Try

RewriteCond %{REQUEST_URI} =/register/user_type
RewriteCond %{HTTP_HOST} ^(?:subdomain\.|)(.*)
RewriteRule "" %{ENV:PROTO}://subdomain.%1/register [R=301]

- instead %1of the third line, it is substituted, what falls into (.*)the second.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question