Resolved Redirect cgi-bin files to website home page

Dick Raney

New Pleskian
I'm working on an eCommerce website that recently converted from a CGI script shopping cart to WordPress with WooCommerce. Google and other websites have links to the products with URLs that look similar to this:

http://www.jirehsupplies.com/cgi-bin/commerce.cgi?search=action&keywords=JSWS010008

which just gets a default Apache 404 error page. Plesk is not handling these links the same way it handles other 404 errors like this:

http://www.jirehsupplies.com/no-such-page.html

which get a custom 404 page.

I have tried to add 301 redirect rules to .htaccess file and nothing works. They have no effect on the cgi-bin URLs. I have also tried disabling CGI for the domain in Plesk, but that didn't help either.

How can I redirect ALL /cgi-bin/commerce.cgi URLs to the website home page?
 
Hi Dick Raney,

I have tried to add 301 redirect rules to .htaccess file and nothing works
Did you consider to use "nginx" - redirects, because your domain is using nginx in front of apache ?
Code:
Content-Encoding:gzip
Content-Type:text/javascript
Date:Tue, 26 Sep 2017 00:30:04 GMT
ETag:W/"59a83287-c8bba"
Last-Modified:Thu, 31 Aug 2017 16:00:07 GMT
Server:nginx
Vary:Accept-Encoding
X-Powered-By:PleskLin
 
I haven't tried that. Not sure how to do it. I just tried a few variations of this code entered into the Plesk Additional nginx directives panel.
rewrite ^(/cgi-bin/commerce.cgi) https://www.jirehsupplies.com last;
return 301;​

But that just takes me to the URL requested URL without the cgi-bin/commerce.cgi portion and gives me a blank Nginx 301 Moved Permanently page. The URL still has the
?search=action&keywords=JSWS010008 bit after the domain name.

Any idea how I might get it to work? I was using this page as a guide to the rewrite rules
 
Hi Dick Raney,

you are missing the dynamic content at your rewrite. If you desire to redirect all ".../cgi-bin/commerce.cgi?..." - URLs, you should use something like:
Code:
    if ($args ~ "^(.*)?search=action$"){
        set $rule_0 1;
    }
    if ($rule_0 = "1"){
        rewrite ^/cgi-bin/commerce.cgi$ https://www.jirehsupplies.com permanent;
    }
 
Hi Dick Raney,

I think, that this should work for you:
Code:
rewrite ^/cgi-bin/commerce.cgi(.*)$ https://www.jirehsupplies.com permanent;
 
That is almost it. At least it redirects to the site, but it takes me to the blog page instead of the home page. I think because it is keeping the ?search=action&......
Is there a way to specify a page and leave off the ?search..... part? There are other URLs that have ?preadd=action.....
I want to specify the exact URL

Thanks again for helping with this!!
 
Hi Dick Raney,

I want to specify the exact URL
You mean, that you can't add the desired "index.php"/"index.html" ( or whatver you desire to redirect to ) to "jirehsupplies.com" ? :(

Pls. feel free to adjust the provided EXAMPLE to your very own needs and desire. :)
 
Back
Top