Gossamer Forum
Home : General : Perl Programming :

.htaccess again :)

Quote Reply
.htaccess again :)
What should be added to the .htaccess file in order to redirect all hits to any file (HTM, HTML, TXT, CGI, PL, ZIP,even 404 error) in every directory to the other website?
I just moved out from http://find.virtualave.net to http://www.cellwarp.com
And now I want to redirect all my visitors to my new location.

And last, if some one could point me to a good FAQ about .htaccess Smile

Thank you.
Quote Reply
Re: .htaccess again :) In reply to
Just put this,

Code:
Redirect / http://www.cellwarp.com

I go to the apache site for .htaccess stuff: http://www.apache.org/.../mod/directives.html
Quote Reply
Re: .htaccess again :) In reply to
As I understand, this will redirect all hits to http://find.virtualave.net/
But what if the URL will be this: http://find.virtualave.net/cgi-bin/hiddendir/links.exe will it also redirect all hits to this file?
Quote Reply
Re: .htaccess again :) In reply to
I tried this false URL:
http://find.virtualave.net/cgi-bin/hiddendir/links.exe
It didn't redirected me to the new location, but it gave me 404 instead. Plus my default 404 error page wasn't displayed as it always was. And it made my other pages (which are online) to give me a 404 error without 404 page.

Any ideas?
Quote Reply
Re: .htaccess again :) In reply to
Try putting a back slash in the end, like this:
Code:
Redirect / http://www.cellwarp.com/
It should work

------------------
Rogerio Morais
http://www.rogerle.com
Quote Reply
Re: .htaccess again :) In reply to
Redirect is a bit of a bugger, because it uses the requested url to create a new one. So it really depends on what you want, and I'm not 100% sure about that, so I'll tell you both ways of doing it.

If the structure of your site on the new server is the same as the old server, and you want to redirect request to the files new location, you can use Redirect. The trailing slash *shouldn't* matter, because most webservers automatically rewrite urls with it if they can't find a file of that name, but you should add it anyway just in case:

Redirect / http://newserver.com/

You can also use mod_rewrite to do it, like this:

RewriteEngine on
RewriteRule ^/(.*)$ http://newserver.com/$1

However, if the structure of the new site *isn't* the same, or even if it is and you want all urls on the old server redirected to one url on the new one, you'll have to use mod_rewrite, like this:

RewriteEngine on
RewriteRule ^/.* http://newserver.com

or:

RewriteEngine on
RewriteRule ^/.* http://newserver.com/someurl.html

The trailing slash definetly isn't important on the last one there.

Of course using mod_rewrite is dependant on the module being compiled into the server, but if it isn't, it should be! Smile

Be warned, my regular expressions aren't the best in the world, so they mightn't be 100% accurate, but they should be. If you have any problems, just post here again and I'll do my best to correct any errors.

Cheers,
adam
Quote Reply
Re: .htaccess again :) In reply to
Oh well. I will just delete everything on my old site, and redirect my 404 error page to my new server Smile

Thank you guys anyway.
Quote Reply
Re: .htaccess again :) In reply to
After all that! I'll never post again! Smile
Quote Reply
Re: .htaccess again :) In reply to
dahamsta,
I mean that I found that it's easier for me to do it this way. And I don't want all search engines (specially altavista) to have my "blank pages". When I will resubmit my whole site again, the search engines will figure out that the pages are not available, and will delete their entries too. Then, I will resubmit my site to all search engine again. This way I don't spam search engines with useless content.
It may sound "nuts", but on the other hand, if we all do the job honestly, then we will all profit.
Your information was very useful to me. Thank you.
Quote Reply
Re: .htaccess again :) In reply to
This worked for me:

Even if the user requested something like: http://www.pbbt.com/dir/Stuff/ it would be rewritten as http://www.pbbt.com/Directory/Stuff/

The permanent tells the browser (or spider or links operator) that the page has pernemently moved.

Redirect permanent /directory http://www.pbbt.com/Directory
Redirect permanent /dir http://www.pbbt.com/Directory
Redirect permanent /Dir http://www.pbbt.com/Directory

Owen