
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
To remove the .html extension from a file, for example, Domain.com/admin.html to Domain.com/admin you have to add the mentioned below code in the .htaccess file.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]
By including the above appropriate code you can remove the extension. You can also remove the PHP extension of the particular folder that is if you want to remove the Index.php successfully from your website URL then you need to make sure that the mod_rewrite module is enabled on your server. So to know whether the mod_rewrite module is enabled or not you can contact our support team and they will help in this case.
But you can also try a technique called URL rewriting where it allows you to hide the index.php portion of the URL behind the scenes. To remove the “index.php” from your site’s URLs, you need to make sure your server is set up to pass 404 requests off to index.php file behind the scenes.
In Apache, you need redirection code in your site’s .htaccess file. If there is no .htaccess file existing (also check if the .htaccess file is present in the hidden files)then you need to create a new file called “.htaccess” in the site’s web root directory.
Adding the below code in the .htaccess file you can remove the extension for a specific folder. Here the code index.php file is taken as an example. For removing the extension for any other folder you need to replace the index.php with the desired file name.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule
But sometimes there will be some problems like links returning 404s, No Input File Specified error or all links may returning to the same content. So, in that case, you can force query strings. And still, if you are facing the same issue then you can rename .htaccess to something else and set the name of your website's index page in the cPanel back to index.php.
If your website is using CodeIgniter framework and you need to remove the index.php from the URL then you can do it by removing it from the config file and with a proper .htaccess file with rewrite rule to remove .htaccess file, If index.php is removed without proper a proper .htaccess file or configuration steps then the site will show 404 Error page.
If you need any assistance, feel free to contact our technical team members as they are available 24/7 via phone call, email, ticket system or call out no 9863075120.
[ad_2]Advertisement