I have an e-commerce site that resides in:
When a customer clicks on the signin link, the browser gets redirected to another domain, in order for authentication:
I'm trying to rewrite http://dev.gworks.mobi/*
to http://frock.gworks.mobi:8080/openam/*
, without redirection.
I've tried this in the .htaccess
of the dev.gworks.mobi
site:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/openam(.*)$ [NC]
RewriteRule ^(.*)$ http://frock.gworks.mobi:8080/$1 [P,L]
</IfModule>
But when I access http://dev.gworks.mobi/openam
, it shows a 404 page not found
page.
Can anyone help me to achieve my use case?
Try this:
This will rewrite all the requests to
dev.gworks.mobi/openam
tofrock.gworks.mobi:8080
.If you want to mask the URI in a way that it's not visible to the visitor that she's visiting the authentication app, you need to add a
P
flag. Please note that it needs Apache'smod_proxy
module in place:Feel free to drop the
L
flag, if it's not the last rewrite rule. See RewriteRule Flags for more information.The 404
If it's all in place and you're still getting a 404 error, make sure that the target URL is not throwing 404 errors in the first place.
Second, check if you're still getting the error with the correct referrer URI set. It might be designed in a way to throw a 404, if the referrer is not correctly set. If that's the case, which I suspect, you need to use the
R
flag and redirect instead of proxying the request.Last thing that comes to my mind, some webapps are not built in a way to figure out the URI address. The host, as well as the port number, might be hard-coded somewhere in the config files. Make sure that the authentication app is able to be run from another URL without the need to edit the configs.
Test
You can test the rewriterule online: