View previous topic :: View next topic |
Author |
Message |
mg66 -
Joined: 15 Aug 2004 Posts: 85 Location: USA, Illinois
|
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Mar 24, 2005 12:38 am Post subject: Re: 301 Redirects Question |
|
|
mg66 wrote: | Since I have 2 domains now and I split all my hunting stuff to the new domain www.bghi.us I have a small dilema.
Can I do a 301 redirect like is used in htaccess file within Abyss X2 so any already spidered urls that point to the old web site automatically redirect to the new urls? |
This feature is not yet available in the Abyss Web Server, it will be added soon. Meanwhile you can use a script to simulate it (but it depends). We recommend contacting us and giving us some sample URLs and we'll tell you how to do. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Mar 24, 2005 4:28 pm Post subject: Re: 301 Redirects Question |
|
|
mg66,
Here is a simple script in PHP that can do what you ask for. Call it for example 404.php and configure it to be your custom 404 error page.
Code: |
<?php
/* Add in this array the list of (old path => new path) pairs */
$redirection = array(
"/old/myoldarticle.html" => "/myarticle.html",
"/data/image.jpg" => "/pwrabyss.gif"
);
$uri = $_SERVER["REDIRECT_SCRIPT_NAME"];
$new_uri = $redirection[ $uri ];
if ($new_uri)
{
header("Status: 301 Moved Permanently");
header("Location: $new_uri");
exit;
}
?>
<!-- Your 404 error page -->
<HTML>
<HEAD>
<TITLE>
Not Found
</TITLE>
</HEAD>
<BODY>
The object <tt><?php echo $uri; ?></tt> is not available.
</BODY>
</HTML>
|
All you have to is to customize the last part of the page and to fill the $redirection array with the old/new paths pairs. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
mg66 -
Joined: 15 Aug 2004 Posts: 85 Location: USA, Illinois
|
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Fri Mar 25, 2005 9:33 pm Post subject: |
|
|
But dude you should use PHP , this script rules , im now able to do URL Rewrites
on my web pages , I hate telling people that a file/dir changed , problem solved.
Last edited by TRUSTAbyss on Sat Mar 26, 2005 9:46 pm; edited 1 time in total |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Fri Mar 25, 2005 10:54 pm Post subject: |
|
|
mg66 wrote: | Thanks for the quick reply and code. Unfortunately I do not run php. |
What is the language you use? We can convert the script quickly. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
mg66 -
Joined: 15 Aug 2004 Posts: 85 Location: USA, Illinois
|
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Mar 26, 2005 11:39 pm Post subject: |
|
|
mg66 wrote: | I use Perl. Version 5 I believe. |
So we'll convert it to Perl and post it here :-) _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Mar 28, 2005 6:03 pm Post subject: |
|
|
Here is the Perl version:
Code: |
# Add in this array the list of (old path => new path) pairs
%redirection = (
"/old/myoldarticle.html" => "/myarticle.html",
"/data/image.jpg" => "/pwrabyss.gif"
);
$uri = $ENV{ "REDIRECT_SCRIPT_NAME" };
$new_uri = $redirection{ $uri };
if ($new_uri)
{
print "Status: 301 Moved Permanently\n";
print "Location: $new_uri\n\n";
exit;
}
print <<EOM;
<!-- Your 404 error page -->
<HTML>
<HEAD>
<TITLE>
Not Found
</TITLE>
</HEAD>
<BODY>
The object <tt>$uri</tt> is not available.
</BODY>
</HTML>
EOM
|
_________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
mg66 -
Joined: 15 Aug 2004 Posts: 85 Location: USA, Illinois
|
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Fri Apr 08, 2005 4:23 pm Post subject: |
|
|
I found an even better way , using an Aliases you can properly redirect the
visitor to the changed page. Their's always a limitation when it comes to a
script so if you decide to use this , only html/php files will work.
Purpose of this new version:
Properly redirects IE users that didn't disable their Show errors option
and so when a person requests a file on Internet Explorer , they will
get properly redirected because the old file name is the aliases.
Installing This new version:
01. Save the code in a file named redirect.php and put it in your
htdocs or anywhere you think would be a good place to put it at.
Code: |
<?php
$redirection = array(
"/old.html" => "/new.html",
"/old2.html" => "/new2.html");
$uri = $_SERVER["REQUEST_URI"];
$new_uri = $redirection[$uri];
if ($new_uri)
{
header("Status: 301 Moved Permanently");
header("Location: $new_uri");
exit;
}
?>
|
02. Edit the Array just like Aprelium explained above and seperate
each new URL Rewrite record with a comma. Open your console.
03. Add an Associated extension for PHP as htm and html then go to
the Aliases section and add an aliases for each old file that you want
to redirect people from , here's a short example on doing this.
File Aliases: Example
Virtual Path: /old.html
Real Path: htdocs/redirect.php
Note: If you are redirecting someone using a sub folder path and not
with a file name , you will have to add that path to the Script Paths. |
|
Back to top |
|
 |
mg66 -
Joined: 15 Aug 2004 Posts: 85 Location: USA, Illinois
|
|
Back to top |
|
 |
|