Last active
March 19, 2026 15:40
-
-
Save artlung/bb8f1471292002071907557e9d038819 to your computer and use it in GitHub Desktop.
Redirects to a different search path, in Perl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings FATAL => 'all'; | |
| my $query = $ENV{'QUERY_STRING'} || ''; | |
| my ($words) = $query =~ /words=([^&]+)/; | |
| if (defined $words) { | |
| $words =~ s/\+/ /g; # Replace + with space | |
| $words =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; # Decode URL-encoded characters | |
| print "Location: /search/?q=$words\n\n"; | |
| } else { | |
| print "Location: /search/\n\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment