|
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-16-2005 14:48
Might be a silly question but...
I have a computer here at work that is broadcasting to the outside so that customers can get to it. If I have a website hosted say at Dreamhost, is it possible to use mod_rewrite to make it look like they are still on the website instead of the computer here?
Right now the computer just has an IP address that can be accessed. Let's say 10.10.10.10/myStuff
This is the computer here that can be seen outside. If I have a webpage, let's say http://www.mydomain.com and I have a link that points to the 10.10.10.10/myStuff, can I rewrite the 10.10.10.10/myStuff so that it reads http://www.mydomain.com/myStuff?
Hope that makes sense
The only thing is, is that the computer here runs IIS. It has to, no way around it. So that may or may not be a problem.
Anyway, thanks in advance!
Later,
C:\
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 12-16-2005 19:23
The answer to your question is: yes you can set up a a mod_rewrite on the DreamHost computer that will point any access to your local computer. This can be done without changing the URI shown in the user's browsers.
The problem I see is that the IP address you've given is part of a private range of IPs. Any IP in the 10.x.x.x range is a private IP and shouldn't be broadcast on the web. If the IP you gave was only an example and not the real address of the machine, then putting something like the following in your .htaccess file at Dreamhost should redirect any request to your local machine
code:
RewriteEngine on
RewriteCond %{REQUEST_URI} /MyStuff$
RewriteRule /MyStuff/(.*) 10.10.10.10/local-dir/$1
.
-- not necessarily stoned... just beautiful.
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-16-2005 19:45
quote:
hyperbole said:
The problem I see is that the IP address you've given is part of a private range of IPs.
That was just an example I didn't want to post the actual IP of the machine. I'll give this a go. Thanks!
Later,
C:\
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-16-2005 20:35
ok....i must have done something wrong
I have this URL on my local macine : 10.10.10.10/oce
If I have my website such as http://mygroovywebsite and I have this link /oce/ and I want it to read in the address bar as http://mygroovywebsite/oce/ but it is actually going to 10.10.10.10/oce, I use your above code like:
code:
RewriteEngine on
RewriteCond %{REQUEST_URI} /oce$
RewriteRule /oce/(.*) 10.10.10.10/oce/$1
I was looking to see what the first section of the RewriteRule does because that is one thing that is confusing me But I couldn't figure out what is was doing.
Later,
C:\
|
zavaboy
Bipolar (III) InmateFrom: f(x) Insane since: Jun 2004
|
posted 12-16-2005 22:00
Don't you need the http:// before the IP?
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-16-2005 22:24
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 12-17-2005 18:57
I think what you want to do is add the [R=302,L] flags to the end of the RewriteRule
You said the script I posted is confusing you so let me go through it line by line.
This line ensures that the RewriteEngine is working. If it is off by default at your site, no URLs will be rewritten. This line just ensures that you can use the mod_rewrite rules to re-write URLs.
code:
RewriteCond %{REQUEST_URI} /MyStuff$
This line tells the module which URLs to match. It says to look at the part of the URL after the first '/'. (The REQUEST_URI). If this part contains the (regular) expression /MyStuff and ends there, then execute the following RewriteRule. Otherwise skip to the next RewriteCond or use the URL as written.
code:
RewriteRule /MyStuff/(.*) 10.10.10.10/local-dir/$1
This line is the one you said your having problems with. The module compares the URI with the expression following the word RewriteRule. In this case the expression is /MyStuff/(.*). This will match the word 'MyStuff' and creates a copy-group of anything that follows the second '/'. (That is what the parentheses are for). You can have several copy-groups if you want by adding more expressions in parentheses. Each copy group is referred to by a number associated with its position in the expression. For example, using the expression (abc)/(def)/(ghi), we would match any URL containing abc/def/ghi and the first copy-group ($1) would contain 'abc'. $2 would contain 'def' and $3 would contain 'ghi'.
The third argument on the RewriteRule line tells the module what to do with the URL. In your case I told it to change the address to 10.10.10.10/local-dir/$1. This will take all the directory and file information from the original URL and append it to the new URL.
For example a request for http://www.mydomain.com/myStuff/dir1/dir2/my-file.html should be redirected to 10.10.10.10/local-dir/dir1/dir2/my-file.html
In order to have this work properly, we should probably take the '$' off the RewriteCond. That along with the flags I suggested above would make the .htaccess file look like:
code:
RewriteEngine on
RewriteCond %{REQUEST_URI} /oce
RewriteRule /oce/(.*) 10.10.10.10/oce/$1 [R=302,L]
I'm not sure about the 302. It means TEMPORARILY MOVED. You could actually leave it off the R flag because it is the default when a code is not specified, But I vaguely remember that the browser will not change the displayed URL if the return code is 302. Maybe someone else can verify this.
Anyway, try this and we'll continue to see if we can't get it to work for you
.
-- not necessarily stoned... just beautiful.
(Edited by hyperbole on 12-17-2005 19:02)
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-19-2005 17:57
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 12-19-2005 20:36
OK, you're getting a 404. Is that from the external server or from the local server?
If your getting the 404 from the external server, it means that it is trying to find the new page on the external.
If the 404 is coming from the local server, the external has successfully re-directed the request, but Apache (or whatever web server you're using locally) is not set up properly on the local server.
Have you looked at the error logs on the external server? That would tell us a lot about what is happening when you make a request like http://mygroovywebsite/oce/.
.
-- not necessarily stoned... just beautiful.
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-19-2005 22:18
It's coming from the external server. In the address bar it still has the external address just a 404.
I have not looked at the error logs yet but I will. The internal server is running IIS and the external is running Apache. Not sure if that is the problem or not.
Thanks for the help!
Later,
C:\
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 12-20-2005 19:29
The fact that the address bar doesn't change doesn't really tell us anything since the server can do a redirect without changing the displayed address in the browser.
Hopefully there is a difference between the 404.html pages on your ineternal and external servers so that we can get positive confermation about which server is generating the 404.
The error logs will probably tell a lot. I suspect that we are not translating the address correctly and the external server is trying to serve a page that doesn't exist.
There should be no problem with using two different servers (Apache and IIS). They are both using http so when the connection moves from the external to the internal server we are doing it with http packets. The two servers are not actually talking to each other.
I'm glad your external server is the Apache server since I'm not very familiar with IIS. I assume it uses the same .htaccess that apache does; not that it really matters since we are only going to do the redirect from the external server.
.
-- not necessarily stoned... just beautiful.
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-20-2005 20:48
quote:
hyperbole said:
Hopefully there is a difference between the 404.html pages on your ineternal and external servers so that we can get positive confermation about which server is generating the 404.
It is in fact the external server
here is the error log from where i just tried to get to it:
code:
[Tue Dec 20 14:24:31 2005] [error] [client ***.***.***.***] File does not exist: /var/www/htdocs/oce/
so, from what i can tell the Apache server is not doing it's job and just thinks that there is supposed to be a directory called "oce" which there is not.
here is what the access_log says:
code:
***.***.***.*** - - [20/Dec/2005:14:24:31 -0500] "GET /oce/ HTTP/1.1" 404 283
quote:
hyperbole said:
I'm glad your external server is the Apache server since I'm not very familiar with IIS.
I know NOTHING about IIS
Later,
C:\
(Edited by CPrompt on 12-20-2005 20:50)
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 12-21-2005 18:57
Have you prefaced the resulting URL in the RewriteRule with 'http://'?
That was laziness on my part not writing it in to my example.
Apache looks for the string 'http://' at the start of the substitution string in the RewriteRule and replaces the old host name with the one specified in the substitution string, but, only if 'http://' is present. Otherwise it assumes that the substitution string points to a local file and makes the substitution, then adds the local host back onto the URL before processing it.
.
-- not necessarily stoned... just beautiful.
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-22-2005 17:08
yeah I had actually added that myself. Not real sure what is going on. It would be nice to have it work like that but I'm gonna have to put it on the back burner.
Boss has given me about a million things to do before the end of the year! Thanks so much for all the help.
Later,
C:\
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 12-22-2005 18:01
Yeah, I understand.
I'm curious about why it doesn't work. If you figure out how to make it work let me know.
.
-- not necessarily stoned... just beautiful.
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 12-22-2005 19:10
quote:
hyperbole said:
If you figure out how to make it work let me know..
will do. thanks again for all the help.
Later,
C:\
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 01-09-2006 19:29
ok. So I must have just been asleep when I did this the last time, but it works. Thanks a bunch for the help!
I do have one more question. If I also need to reroute something like this :
http://10.10.10.10/oce/Oms/ClientDownload/Default.aspx
and I just want to get rid of the 10.10.10.10 and replace that, I was thinking the above should just do it, but I actually got 505's all over the palce
Thanks for all the help.
Later,
C:\
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 01-09-2006 20:15
well I thought it was working. But it's not.
Here is the .htaccess that I have:
And that is the correct IP so you will be able to see the page.
Later,
C:\
(Edited by CPrompt on 01-09-2006 20:26)
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 01-09-2006 22:39
The code you have above says if a request arrives with /oce in the path, redirect it to 207.14.224.87. For all other requests search the uri for the word driver and add whatever follows to the end of a new uri. It will try to do this even if it can't find the word driver in the request.
I think you ought to add another RewriteCond to the code.
See if that doesn't help.
The 505 is not a direct cause of the .htaccess file. It means the HTTP version in the request isn't supported by the server. I think this may be caused by garbage being passed on to the server when you make a request that doesn't have the word driver because the regexp in your second RewriteRule doesn't match anything in the uri, but it tries to Rewrite the uri with nothing anyway.
.
-- not necessarily stoned... just beautiful.
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 01-10-2006 00:28
here's the error log
code:
[Mon Jan 09 18:21:59 2006] [error] [client 000.000.000.000] File does not exist: /home/virtual/site9/fst/var/www/html/oce
[Mon Jan 09 18:22:05 2006] [error] [client 000.000.000.000] File does not exist: /home/virtual/site9/fst/var/www/html/driver
I am using mod_rewrite to make purty URL's so if that makes a difference here is the entire .htaccess
Later,
C:\
(Edited by CPrompt on 01-10-2006 00:28)
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 01-10-2006 16:40
I'm running out of ideas.
Two things:
1) Try adding 'Options FollowSymLinks'
2) I assume this .htaccess file is in the directory /home/virtual/site9/fst/var/www/html/. If it is not, you need to move it there or we need to change the RewriteBase to the directory where it resides.
.
Oh, another thought just occurred to me:
Was
code:
RewriteRule ^(about|estimate|contact|commercial)(/)?([a-zA-Z0-9_]*) /index2.php?link=$1 [L]
working before we started adding the redirects for 207.14.224.87? Is it still working properly? Does removing or adding the redirects to the server change the way that rewriterule works?
-- not necessarily stoned... just beautiful.
(Edited by hyperbole on 01-10-2006 16:46)
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 01-10-2006 17:31
Thanks for all your help hyperbole. I actually added the Options FollowSymlinks today with no luck.
The other rewrites are working just fine. If I take them out the REQUEST_URI stuff still doesn't work. Now I just get a 404 error so it is like the Apache server where the website is, is not doing it's job with it.
Eigh....I'll mess with it for a little while longer and then move on to another project.
Thanks for all your help!!!!
Later,
C:\
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 01-10-2006 23:57
Of course I just can't leave it alone I'm just gonna keep on posting about my attempts at this.
I added this :
and now if I type in http://mysite.com/oce/ it redirects to http://207.14.224.87/oce/
That's all well and good but I would *really* like for the URL in the address bar to not change to the IP address. I'll keep on working on it.
Later,
C:\
|
hyperbole
Paranoid (IV) InmateFrom: Madison, Indiana, USA Insane since: Aug 2000
|
posted 01-12-2006 21:45
It occurred to me this morning that with the listing you gave above of your .htaccess file and actual IP address, I could place the RewriteRules in my .htaccess file and play with it.
I have noticed the following things
1) apparently the redirect only happens to an external address if you are replacing the entire URL in the RewriteRule. For example
works.
does not.
Apache seems to ignore the first rule.
2) You can make the redirect to driver work with the following
Since we need to match the entire URL in the RewriteRule, i.e, with .*, I placed a matching group in the RewriteCond statement and copied it into the resulting URL with a %1 instead of $1. This allows you to eliminate the /driver/ directory from the resulting URL.
3) The line
code:
Options +FollowSymLinks
should have a plus sign (+) in-front of the FollowSymLinks parameter. I don't know that this is required, but it helps with some servers and makes the file a little more readable.
4) Apparently the URL in the browser window will always be rewritten because we are doing an external redirect (that's what the [R] flag does). If you do an internal redirect (i.e. to a file on the local server), the URL on the browser won't be rewritten. This could be accomplished by redirecting the oce requests to a CGI file on the local server and letting it generate a page with a reference to the desired page on 207.14.224.87, for example, with a frame set.
This is, I think, a very ugly solution, but it might get you on the right track.
.
-- not necessarily stoned... just beautiful.
|
CPrompt
Maniac (V) InmateFrom: there...no..there..... Insane since: May 2001
|
posted 01-13-2006 04:21
hmmm....I was thinking that it might be something like that as far as rewriting the URL on the local machine to match the external server. I was playing around with the internal server today (and crashed it a few times) seeing if I could do something there to make the URL stay at the external URL.
I think you might be on to something with the frame set. I might be able to get it to do that. Not sure. I need to find something to read on how to get it to do that. I am sure it is pretty easy to just make an iFrame or something to load the page into. It might be ugly but I really don't want our clients to think their computers are being *hi-jacked* or something malicious.
The only other thing I can think of is to get a seperate DSL line ran with some sort of business account and have it going directly to that server. That just seems like a bit more money to spend than what it's worth.
I appreciate your help.
Later,
C:\
|