Forum Moderators: phranque
www.site.com/cgi-bin/olddirectory/file.html
The new links are:
www.site.com/cgi-bin/newdirectory/file.html
The .htaccess isn't working on the cgi-bin (which I kind of understand why from reading other threads).
Is there a way around this though? What can I do so that all my old links are redirected correctly?
1. Create a file in the OLD directory called 404.pl,
Here's the code for 404.pl
#!/usr/bin/perl
print "HTTP/1.0 301 Moved Permanently\n";
print "Location: /new-folder/$ENV{'SCRIPT_NAME'}\n";
print "Content-type: text/html\n";
print "\n";
print "<html>\n";
print "<head>\n";
print "<title>301 Permanently Moved</title>\n";
print "</head>\n";
print "<body>\n";
print "<h1>Permanently Moved</h1>\n";
print "The document has moved <a HREF=\"/new-folder/$ENV{'SCRIPT_NAME'}\">here</a>.<p>\n";
print "</body>\n";
print "</html>\n";
exit;
# End Code
----------------------------
2. CHMOD 404.pl to 755 (execution rights)
3. Create a .htaccess in the OLD directory and add this line:
ErrorDocument 404 404.pl
That should do it - let me know!