PDA

View Full Version : Help me rewriting this URL


ranjith
08-29-2005, 07:47 AM
I have a file aboutus.html in www.domain1.com

I want to access this file from www.domain2.com

While rewriting, the URL in the address bar should be www.domain2.com/aboutus.html.

:(

nikkiH
08-30-2005, 11:16 PM
Mod Rewrite? (http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html)

ranjith
09-01-2005, 02:51 PM
Yes, using Mod Rewrite.

I tried this piece of code
RewriteEngine ON

RewriteRule ^aboutus\.html$ http://www.domain1.com/aboutus.php [R=301,L]

Redirecting, but the address bar also changes to
http://www.domain1.com/aboutus.php
i dont want this to happen. I want the address bar to show
http://ne.domain2.com/aboutus.html

:-(

nikkiH
09-01-2005, 03:46 PM
Sorry, my bad. I can read.
That was wrong.


Use proxy instead of redirect.

[R] stands for redirect. The default is 302, temporarily moved. This can be set to any number between 300 and 400, by entering it as [R=301] or [R=YourNumberHere], but 301 (permanently moved) and 302 (temporarily moved) are the most common.
...
[P] stands for proxy. This creates a type of 'silent redirect' for files or pages that are not actually part of your site and can be used to serve pages from a different host, as though they were part of your site.

ranjith
09-02-2005, 10:19 AM
Thank you nikkiH ,

Its working, but for few files i use secured connection.

If i use

RewriteRule ^aboutus\.html$ http://www.domain1.aboutus.php [P]

it is works perfectly

But

RewriteRule ^aboutus\.html$ https://www.domain1.aboutus.php [P]

It gives an internal server error.

nikkiH
09-02-2005, 03:23 PM
Are you changing the protocol as you need to for https?
RewriteCond %{SERVER_PROTOCOL} !HTTPS

Also, to use both http and https with mod_rewrite, I think you must have two .htaccess files or it gets into an endless loop problem. So they must be in separate directories. Are they?

ranjith
09-03-2005, 07:13 AM
This is the code in my .htaccess file on domain2:

RewriteEngine ON

RewriteRule ^index\.html$ index.php [L]

RewriteRule ^aboutus\.html$ http://www.domain1.com/about_us.php [P]

RewriteRule ^donations\.html$ https://www.domain1.com/donations.php [P]


In this the aboutus.html is redirected, but the donations.html is giving an error.
How to do this:

RewriteRule ^donations\.html$ https://www.domain1.com/donations.php [P]

nikkiH
09-06-2005, 04:55 PM
I don't think you can if you have that all in one directory on the server. You need more like

RewriteRule ^donations\.html$ https://www.domain1.com/secure/donations.php [P]