Revive Perl Script for Linux
Budget: $10 – $30 USD
At least 10 years ago, I found a script on the web and it has worked great.
I moved to a new hosting company and can't get it to work. Would anyone be able to help?
On my shared hosting service in /public_html, i have an index.cgi file with this script below.
It allows me to type a subdomain URL of my domain and it would redirect to a URL I set up in the script.
Effectively a long list of shortcuts.
like chrome.example.com would get the ninite chrome installer sphere.example.com would go to the youtube live feed.
if I type a subdomain that didn't have a shortcut, it would take me to my website.
I got it working years ago and would edit it just to deal with shortcut additions, deletions & changes. I really don't know the first thing about programming.
I copied my public_html folder from the old to new host. I made sure index.cgi had 755 permission.
The .httaccess came over also.
The first line in .htaccess - #!/usr/local/bin/perl - I didn't / don't have a bin or perl folder anywhere in my directory tree on old OR new server
My DNS zone has an a record for * pointing to my server's IP address, as before.
When I type something like sphere.example.com now, it redirects to:
http://sphere.example.com/cgi-sys/defaultwebpage.cgi which is a cpanel page saying "**SORRY! If you are the owner of this website, please contact your hosting provider**"
If I type www.example.com or example.com, I get:
**lscgid: execve():/home/feetsdr/public_html/index.cgi: No such file or directory**
If you know of another way for a way to set up shortcuts or what I can do for this page, please let me know!
```
#!/usr/local/bin/perl -w $mainpage = "index.html"; %domains = (
'www.example.com ' => 'https://www.example.com ',
'sphere.example.com' => 'https://www.youtube.com/watch_popup?v=_JChRujRMrg&autoplay=1&mute=1 ', #the sphere las vegas
'www.example.com ' => 'https://www.example.com/index.html '
); $server = lc($ENV{'HTTP_HOST'});if ($ENV{'HTTP_HOST'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/){$t='/'}else{if ($server !~ /^www./){$server = '' . $server;}}@domains = keys(%domains);foreach $domain(@domains){if ($domain eq $server){print "Location: $domains{$server}\n\n";$match="yes";last;exit}}unless($match){print "Location: https://www.example.com/index.html\n\n";exit}exit ;
```
and the .htaccess file is:
```
RewriteEngine on
#RewriteEngine On
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^2082$
RewriteRule .* https://%{SERVER_NAME}\:2083%{REQUEST_URI} [R,L]
# -FrontPage-
AuthUserFile /home/feetsdr/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/feetsdr/public_html/_vti_pvt/service.grp
DirectoryIndex index.cgi index.html
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
ErrorDocument 404 https://www.example.com/404.shtml
AuthName www.example.com
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
```
Yeah, I was using frontpage decades ago. And haven't done much of anything else since.
Feel free to tell me what else I can remove from the htaccess page.
Not sure what / if anything is needed.
There's loads of other shortcut entries. Just left the sphere one in as an example.
THANKS!
I moved to a new hosting company and can't get it to work. Would anyone be able to help?
On my shared hosting service in /public_html, i have an index.cgi file with this script below.
It allows me to type a subdomain URL of my domain and it would redirect to a URL I set up in the script.
Effectively a long list of shortcuts.
like chrome.example.com would get the ninite chrome installer sphere.example.com would go to the youtube live feed.
if I type a subdomain that didn't have a shortcut, it would take me to my website.
I got it working years ago and would edit it just to deal with shortcut additions, deletions & changes. I really don't know the first thing about programming.
I copied my public_html folder from the old to new host. I made sure index.cgi had 755 permission.
The .httaccess came over also.
The first line in .htaccess - #!/usr/local/bin/perl - I didn't / don't have a bin or perl folder anywhere in my directory tree on old OR new server
My DNS zone has an a record for * pointing to my server's IP address, as before.
When I type something like sphere.example.com now, it redirects to:
http://sphere.example.com/cgi-sys/defaultwebpage.cgi which is a cpanel page saying "**SORRY! If you are the owner of this website, please contact your hosting provider**"
If I type www.example.com or example.com, I get:
**lscgid: execve():/home/feetsdr/public_html/index.cgi: No such file or directory**
If you know of another way for a way to set up shortcuts or what I can do for this page, please let me know!
```
#!/usr/local/bin/perl -w $mainpage = "index.html"; %domains = (
'www.example.com ' => 'https://www.example.com ',
'sphere.example.com' => 'https://www.youtube.com/watch_popup?v=_JChRujRMrg&autoplay=1&mute=1 ', #the sphere las vegas
'www.example.com ' => 'https://www.example.com/index.html '
); $server = lc($ENV{'HTTP_HOST'});if ($ENV{'HTTP_HOST'} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/){$t='/'}else{if ($server !~ /^www./){$server = '' . $server;}}@domains = keys(%domains);foreach $domain(@domains){if ($domain eq $server){print "Location: $domains{$server}\n\n";$match="yes";last;exit}}unless($match){print "Location: https://www.example.com/index.html\n\n";exit}exit ;
```
and the .htaccess file is:
```
RewriteEngine on
#RewriteEngine On
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^2082$
RewriteRule .* https://%{SERVER_NAME}\:2083%{REQUEST_URI} [R,L]
# -FrontPage-
AuthUserFile /home/feetsdr/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/feetsdr/public_html/_vti_pvt/service.grp
DirectoryIndex index.cgi index.html
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
ErrorDocument 404 https://www.example.com/404.shtml
AuthName www.example.com
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
```
Yeah, I was using frontpage decades ago. And haven't done much of anything else since.
Feel free to tell me what else I can remove from the htaccess page.
Not sure what / if anything is needed.
There's loads of other shortcut entries. Just left the sphere one in as an example.
THANKS!