Forum Moderators: phranque

Message Too Old, No Replies

how to rewrite url so that address bar doesn't change original url

rewriting url when redirecting to another public domain website

         

Cense_Admin

10:18 am on Sep 18, 2014 (gmt 0)

10+ Year Member



My requirement is like this. We have a university website running on centos 5.5. I need to make one specific url to be redirected to another google website which is on google servers but i need to keep the url in browser to same university website url. I am a newbie in this. I tried using redirect and mod_proxy to accomplish this, but couldn't make it out. Redirect is happening but new website url is appearing in address bar instead of university url.
Scenario is like
example1.com = university server
example2.com = google public hosting site
If user visits "[url]example1.com/abcd[/url]" it should serve the content hosted on example2.com but the address bar should be showing [url]example1.com/abcd[/url] and not [url]example2.com[/url].
As I am newbie in this I need help on which files i need to edit and what changes to make. I had tried using .htaccess and httpd.conf files but I am getting the 503 and 505 errors when I tried to use Proxy using P flag with mod_rewrite. otherwise it shows the example2.com url on the address bar. Please help me.

lucy24

4:40 pm on Sep 18, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



"Serve content from material on a different server and/or a different hostname without changing address bar" is definitely a case for [P]. So we need to figure out where the 503 errors are coming from. (505? Really? I had to go look that up.)

You'll have to grit your teeth and quote the exact ruleset that caused the 50x error. I assume you're allowed to use mod_rewrite in other situations, so that by itself isn't the source of the error. All too often it turns out to be a simple typo. Apache is very unforgiving.

phranque

8:51 pm on Sep 18, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, Cense_Admin!


is your server returning the 503 or the google public hosting site?

lucy24

6:54 am on Sep 19, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



is your server returning the 503 or the google public hosting site?

Dang, phranque, that's a good question ;) If you're [P]-ing to an entirely different server, can that second server return a 503 that will be, er, retro-proxied back up the line? Or would it come through as a 400-class error? ("I dunno what the problem is, but I couldn't get hold of the needed file.")

:: wandering off to figure out if there's any way I can experiment within the confines of htaccess (multiple hostnames but all the same server) ::

Cense_Admin

10:25 am on Sep 19, 2014 (gmt 0)

10+ Year Member



@lucy24.
Sorry. its a 500 error not 505.When I am trying various combinations in syntax after googling the same I used to get either service unavailable or service temporarily unavailable or Internal server error. Following is the excerpt from my httpd.conf and .htaccess files.

.htaccess
RewriteEngine On
RewriteRule ^(.*)$ [example2.com...]

httpd.conf
1st attempt
<Proxy *>
Order allow,deny
allow from all
</Proxy>

ProxyPreserveHost On

ProxyPass example1.com [example2.com...]
ProxyPassReverse example1.com [example2.com...]

2nd attempt
<Proxy *>
Order allow,deny
allow from all
</Proxy>

ProxyPreserveHost On

ProxyPass example1.com [example2.com...]
ProxyPassReverse example1.com [example2.com...]

<Location /foldername/>
Order allow,deny
allow from all
</Location>

3rd attempt
<VirtualHost *:80>
ProxyPreserveHost On

ProxyPass example1.com [example2.com...]
ProxyPassReverse example1.com [example2.com...]

ServerName localhost
</VirtualHost>

4th attempt
<VirtualHost *:80>
ProxyPreserveHost On

ProxyPass example1.com [example2.com...]
ProxyPassReverse example1.com [example2.com...]

#ServerName localhost
</VirtualHost>

I am a complete newbie in all this. So please let me know where am I going wrong. I tried googling for the syntax but i am unable to figure out my typos.

Note : In each of my attempts i commented out my previous modifications
Thanks

phranque

8:27 am on Sep 20, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



the server error log file should show a message relevant to the 500 error code.

Cense_Admin

9:00 am on Sep 20, 2014 (gmt 0)

10+ Year Member



@phranque I am totally newbie in this. Sorry for my dumb question. But which of the server error log you are talking about? error_log or nss_error_log?

phranque

9:15 am on Sep 20, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i would check both.

Cense_Admin

9:52 am on Sep 20, 2014 (gmt 0)

10+ Year Member



I am quoting possible relevant errors here. Please have a look and suggest me the solution for the problem.

[Fri Sep 19 16:09:05 2014] [error] (101)Network is unreachable: proxy: HTTPS: attempt to connect to [2404:6800:4003:c02::8a]:443 (example2.com) failed

[Fri Sep 19 16:09:05 2014] [error] ap_proxy_connect_backend disabling worker for (example2.com)

[Fri Sep 19 16:10:25 2014] [error] (101)Network is unreachable: proxy: HTTPS: attempt to connect to [2404:6800:4003:c02::8a]:443 (example2.com) failed

[Fri Sep 19 16:10:25 2014] [error] ap_proxy_connect_backend disabling worker for (example2.com)

[Fri Sep 19 16:10:27 2014] [error] proxy: HTTPS: disabled connection for (example2.com)

[Fri Sep 19 16:10:28 2014] [error] proxy: HTTPS: disabled connection for (example2.com)

lucy24

7:08 pm on Sep 20, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



:: belated "D'oh!" moment here ::

You're proxying to someone else's server. Don't they have to do something at their end to authorize the proxy? Otherwise anyone, anywhere, could show someone else's content on their own site.

Incidentally-- this will sound like one step forward and two steps back, but did you start out by establishing that a proxy is the best way or the only way to show this content? Have you eliminated other possibilities, like putting the material inside an iframe? *


* Is it just me, or is it really hard not to interpret this as "iFrame"?

Cense_Admin

7:20 am on Sep 21, 2014 (gmt 0)

10+ Year Member



Yes I tried using iframe and oldstyle frames. But both don't work as its a https link. As I told at the very beginning that I am a newbie I might be missing the basic clue also. So please let me know what else I might need to do for this to work. I reiterate I am completely new into this. So I appreciate if you tell me all the steps in a layman's language like dummies books. Can you please guide me how to authorize the proxy at the google site end? I would be grateful if I can solve this issue with that step alone.

not2easy

3:36 pm on Sep 21, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Simple solution could be to use https: for the frame page so it is not showing mixed content. Also make sure that if a certificate is using the www. form, to use that for the connection.

Added: I do not know if the proxy settings needs to be used or has an effect when both sites are https.

lucy24

11:45 pm on Sep 21, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I know next to nothing about proxying, so we need to wait for someone who speaks Apache (looking at you, phranque).

how to authorize the proxy at the google site end

Is it your site? That is, obviously it belongs to google, but do you have access to the server config file? I'm guessing no, and this isn't the kind of thing you can do in htaccess. afaik, mod_proxy directives are limited to config or, at most, virtual host.

I assume there's some reason you can't just park the content on your own site and make the problem disappear that way. Can you get an iframe to work if you follow not2easy's suggestion of giving both pages the same protocol?

Incidentally, I tried the [P] flag on my test site, proxying to another domain on the same server. If you don't have use of* mod_proxy, the error you get is:
File does not exist: proxy:http://www.example.com/dir/filename.html



* That is, it may or may not exist, but I can't do anything about it.