How to remove .cgi from url with .htaccess?

Member

by gilbert , in category: Third Party Scripts , 4 months ago

How to remove .cgi from url with .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jasen , 4 months ago

@gilbert 

To remove the .cgi extension from a URL using .htaccess, you can use the following code:

1
2
3
4
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.cgi -f
RewriteRule ^([^.]+)$ $1.cgi [NC,L]


This code will remove the .cgi extension from the end of the URL and serve the file without the extension. Make sure to place this code in the .htaccess file in the root directory of your website.