0

I want to forward the main domain example.com to the (WIX webspace) domain guenterpolt.wixsite.com/example but not the subdomain moodle.example.com which should stay on my server.

I cannot use DNS for this because WIX gives me no IP, so I must use some kind of HTML/PHP or .htaccess forwarding. HTML/PHP header or meta refresh forwarding forwards all. Is this possible with .htacess and how can I make this work?

closed as off-topic by Tero Kilkanen, kasperd, Ward, mdpc, MadHatter Oct 15 '17 at 5:48

This question appears to be off-topic. The users who voted to close gave these specific reasons:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

Assuming the subdomain is configured as its own virtual host, then you can use a mod_alias Redirect in the main domain's <VirtualHost> container:

Redirect / https://guenterpolt.wixsite.com/example/

I've assumed the target site is HTTPS.

However, if .htaccess is your only option (or the two domains are configured in the same VirtualHost), then you can use mod_rewrite instead to redirect just the main domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^ https://guenterpolt.wixsite.com/example%{REQUEST_URI} [R,L]

This only applies to the main domain.

This will work in either .htaccess or the server config.

Change R to R=301 if this is intended to be permanent.

  • 1
    Thank you very much, this worked fine for me, problem solved. I see I must dig deeper into the rewrite condititons in htaccess which is somehow tricky for me as beginner. thank you! – Johannes Sep 29 '17 at 9:11
0

You have to create the different virtual host file for both websites, i.e one for domain example.com and other subdomain moodle.example.com in Apache or whatever web server you are using.

Example of apache virtual host file.

File name: vhost.conf

Listen 80

    <VirtualHost 172.20.30.50>
       ServerName dr-polt.at
       DocumentRoot "/www/example1"

       # Other directives here ...
    </VirtualHost>


    <VirtualHost 172.20.30.50>
       ServerName moodle.dr-polt.at
       DocumentRoot "/www/example2"
       # Other directives here ...

    </VirtualHost>

You can either add a .htaccess rule in Apache vhost.conf or in .htaccess file for the required domain in the document root directory.

  • Thank you. As I have no access to vhost.conf I went over to the 2nd solution here mentioned which worked well for me. – Johannes Sep 29 '17 at 9:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.