You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jon Shoberg <js...@cbd.net> on 2002/02/04 05:07:33 UTC

mod-rewrite - moving a website ....

I ahve a website which is heavily indexed by search engines.  They often do
direct requests for documents and I would rather not have the web server
send back tons of 404 pages.  THe website structure looked like ...

http://www.mydomain.com
http://www.mydomain.com/index.html

http://www.mydomain.com/page1.html
http://www.mydomain.com/page2.html
...
http://www.mydomain.com/page(N).html

Is my understanding correct that mod_rewrite can take a request for
/page1.html and internally make a request to
/articles/viewdoc.php?v=page1.html such that it is transparent to the
browser-agent?  Could someone provide a simple example of this?

Thanks



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: mod-rewrite - moving a website ....

Posted by kirk Bailey <id...@netzero.net>.
Possibly I am confused.

You are moving to a new server, possibly a entirely new cohosting
site? Are you retaining the name? If so, and you retain the same
internal file names and links, no changes are needed. Make sure you
duplicate the tree with the www dir as the center of it, and all dir's
off it in the same relative locations, and names, and all files the
same names.

When someone at a search service clicks on http://www.mydomain.com,
the fact it is at a new cohost with an entirely new hard IP address is
irrelevant, ONCE THAT NEW ADDRESS PROPIGATES THROUGH NAME SERVER
SPACE. It will take the browser to the correct new machine.

DUPLICATE the site at the new server, and keep the old one running. At
the top of the home page, place some small indicator that the data
comes from the old site, and at the other server that it is coming
from the new site. FTP and telnet can go to hard IP addresses, so this
is not a big challenge.

When my cohosting service changed connectivity vendors, all the IP
addresses changed! I had to deal with this and maintain my email
service by doing ssh and ftp to the new IP address until the name
changes propigated. Such fun...

Hope this helps.

Jon Shoberg wrote:
> 
> I ahve a website which is heavily indexed by search engines.  They often do
> direct requests for documents and I would rather not have the web server
> send back tons of 404 pages.  THe website structure looked like ...
> 
> http://www.mydomain.com
> http://www.mydomain.com/index.html
> 
> http://www.mydomain.com/page1.html
> http://www.mydomain.com/page2.html
> ...
> http://www.mydomain.com/page(N).html
> 
> Is my understanding correct that mod_rewrite can take a request for
> /page1.html and internally make a request to
> /articles/viewdoc.php?v=page1.html such that it is transparent to the
> browser-agent?  Could someone provide a simple example of this?
> 
> Thanks
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

-- 
 

 -Respectfully,
              -Kirk D Bailey 
               Consulting Loose Cannon

end



  www.howlermonkey.net                 highprimate@howlermonkey.net
  www.sacredelectron.org                         idiot1@netzero.net
  www.tinylist.org                              grumpy@tinylist.org


----------------------------------------------------
Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: mod-rewrite - moving a website ....

Posted by Joshua Slive <jo...@slive.ca>.
> From: Jon Shoberg [mailto:jshoberg@cbd.net]

>
> This should do it ! Thanks :)
>
> I would like it applied to every static .html URL from the server root.
> This worked great, but is there a way to change it so it erwrites
> everything
> except the index.html page?  I presume apache uses perl5 style regexp ?

No, apache 1.3 uses egrep-style regexes.

To do that, I think you need
RewriteEngine On
RewriteCond %{REQUEST_URI} !index.html$
RewriteRule ^/([^/]*)\.html /articles/viewdoc.php?v=$1.html

Note I've changed the RewriteRule so it only applies to files in the
DocumentRoot, and not files in any subdirectory.  I'm still not sure if that
is what you want.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: mod-rewrite - moving a website ....

Posted by Jon Shoberg <js...@cbd.net>.
This should do it ! Thanks :)

I would like it applied to every static .html URL from the server root.
This worked great, but is there a way to change it so it erwrites everything
except the index.html page?  I presume apache uses perl5 style regexp ?

Thanks



-----Original Message-----
From: Joshua Slive [mailto:joshua@slive.ca]
Sent: Sunday, February 03, 2002 11:15 PM
To: users@httpd.apache.org
Subject: RE: mod-rewrite - moving a website ....



> From: Jon Shoberg [mailto:jshoberg@cbd.net]


> Is my understanding correct that mod_rewrite can take a request for
> /page1.html and internally make a request to
> /articles/viewdoc.php?v=page1.html such that it is transparent to the
> browser-agent?  Could someone provide a simple example of this?

Yep.  Something along the lines
RewriteEngine On
RewriteRule ^/(.*)\.html /articles/viewdoc.php?v=$1.html

You don't mention exactly which pages you want this rule to apply to.  I've
written it so that it will apply to ever .html on the site.

Use the RewriteLog to help you find tune things.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: mod-rewrite - moving a website ....

Posted by Joshua Slive <jo...@slive.ca>.
> From: Jon Shoberg [mailto:jshoberg@cbd.net]


> Is my understanding correct that mod_rewrite can take a request for
> /page1.html and internally make a request to
> /articles/viewdoc.php?v=page1.html such that it is transparent to the
> browser-agent?  Could someone provide a simple example of this?

Yep.  Something along the lines
RewriteEngine On
RewriteRule ^/(.*)\.html /articles/viewdoc.php?v=$1.html

You don't mention exactly which pages you want this rule to apply to.  I've
written it so that it will apply to ever .html on the site.

Use the RewriteLog to help you find tune things.

Joshua.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org