Forum Moderators: phranque

Message Too Old, No Replies

Redirect to subdomain and keep original URL in address bar

         

Shizuka

2:38 pm on Sep 1, 2016 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hello,

I am looking for following solution. I have a domain called mydomain.com and want to redirect to my subdomain mysubdomain.mydomain.com and keeping the original url in the address bar.

I tried it with RewriteRule :
RewriteRule ^/test.html$ subdomain.domain.com%2 [P,L] 


and

ProxyPass:
ProxyPass /test.html/ subdomain.domain.com
ProxyPassReverse /test.html/ subdomain.domain.com


The redirect and keeping the original URL is working, but every link and images on the redirectetd site is not working. The links and images are linking to the original domain.

Can anyone say what I am doing wrong and advice me?

Thank you.
Shizuka

whitespace

4:18 pm on Sep 1, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



The redirect and keeping the original URL is working, but every link and images on the redirectetd site is not working.


That sounds like a client-side URL problem?

The links and images are linking to the original domain.


You are going to have to proxy the links and images as well.

Where does the subdomain point to on the filesystem? A subdirectory, or an entirely different location?

Shizuka

9:40 am on Sep 2, 2016 (gmt 0)

5+ Year Member Top Contributors Of The Month



You are going to have to proxy the links and images as well.

How can I do this?


Where does the subdomain point to on the filesystem? A subdirectory, or an entirely different location?


The subdomain is on a diffrent server.


Is it even possible?

whitespace

2:30 pm on Sep 3, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



You are going to have to proxy the links and images as well.


How can I do this?


You said that "keeping the original URL is working" - which presumably is being achieved by proxying the request as suggested in your first post? So you would presumably apply the very principle with whatever you are linking to... images etc.

I guess your links are expressed as absolute URLs to mydomain.com?

Shizuka

6:37 am on Sep 5, 2016 (gmt 0)

5+ Year Member Top Contributors Of The Month



You said that "keeping the original URL is working" - which presumably is being achieved by proxying the request as suggested in your first post? So you would presumably apply the very principle with whatever you are linking to... images etc.

I guess your links are expressed as absolute URLs to mydomain.com?


Yes, keeping the URL is working, but no images are shown and no further links are working. Everything is point to the "first" domain mydomain.com/image_1.jpg.

Do you have some examples for me.
Right now I get the URL from the subdomain in the addressbar, when I tried with ProxyPass and ProxyPassReverse.

ProxyPass /test.html subdomain.mydomain.com
ProxyPassReverse /test.html subdomain.mydomain.com


I dont know what I am doing wrong. My oriantation was this post
[stackoverflow.com...]

Shizuka

8:51 am on Sep 5, 2016 (gmt 0)

5+ Year Member Top Contributors Of The Month



Can not edit my previous post...

I think I get it now (almost)

Pictures are loading and the stylesheet is displayed correct.

There is one more thing. The links are linking to the subdomain... any ideas how can I fixed this?

With the first configuration its works, but for the whole path / , I tried it only for "test" but had no luck... any ideas for this problem?


ProxyRequests off
ProxyHTMLURLMap http://subdomain.mydomain.com/ /


<Location />
ProxyPass http://subdomain.mydomain.com/
ProxyPassReverse http://subdomain.mydomain.com/
ProxyHTMLEnable On
ProxyHTMLURLMap / http://subdomain.mydomain.com/
RequestHeader unset Accept-Encoding
</Location>







ProxyRequests off
ProxyHTMLURLMap http://subdomain.mydomain.com/ /test


<Location /test >
ProxyPass http://subdomain.mydomain.com/
ProxyPassReverse http://subdomain.mydomain.com/
ProxyHTMLEnable On
ProxyHTMLURLMap /test http://subdomain.mydomain.com/
RequestHeader unset Accept-Encoding
</Location>

Shizuka

10:31 am on Sep 5, 2016 (gmt 0)

5+ Year Member Top Contributors Of The Month



Cant edit my post again.....

But finally I find a solution.

Keeping the URL is working, pictures and stylesheet is working and further links will be displayed correct :)

ProxyRequests off
ProxyPass /test/ http://subdomain.mydomain.com/
ProxyHTMLURLMap http://subdomain.mydomain.com/ /test

<Location /test/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap / /test/
RequestHeader unset Accept-Encoding
</Location>



Thank you for your help whitepace.

Shizuka

8:19 am on Sep 12, 2016 (gmt 0)

5+ Year Member Top Contributors Of The Month



I need some more help.

I have images and some content there are not displayde, because there are not in the same path "test". How can I load them when the images in
http://subdomain.mydomain.com/images/
?

[edited by: not2easy at 1:01 pm (utc) on Sep 12, 2016]
[edit reason] unlinked for readability [/edit]

Asontym

7:05 am on Oct 14, 2016 (gmt 0)

5+ Year Member



Explain to me, if I can pull it off with my local proxy (advanced.name)? Used to enjoy him, to be honest.