How do i get rid of index php?
To remove the “index.php” from your site’s URLs, you will first need to make sure your server is set up to pass would-be 404 requests off to Craft’s index.php file behind the scenes. Show
If you’re running Apache, you can do that by creating a redirect in your site’s .htaccess file. If you don’t already have one, create a new file called “.htaccess” in your site’s web root. Save this inside your .htaccess file:
That rewrite rule basically says, “if a request is coming in that doesn’t map to an existing folder or file, pass it along to index.php instead.” With that file in place, try accessing a page on your site (besides your homepage), without the “index.php”. If it works, great! If not, you should check with your host to see why the .htaccess file isn’t working. That’s great, but my URLs are still outputting with “index.php” #The last step is to tell Craft that your site is set up to handle URLs without “index.php” in them. (Craft does its best to determine that for itself, but it only checks every 24 hours, and sometimes it gets it wrong.) You can tell Craft not to include the “index.php” by opening up craft/config/general.php, and adding this to the array:
With that in place, Craft will take your word for it and stop performing its daily checks. But seriously, my URLs still have “index.php” in them #If
you’re on Apache, your The original answer is actually correct, but lacks explanation. I would like to add some explanations and modifications. I suggest reading this short introduction https://httpd.apache.org/docs/2.4/rewrite/intro.html (15mins) and reference these 2 pages while reading. https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html https://httpd.apache.org/docs/2.4/rewrite/flags.html This is the basic rule to hide
Think E.g. So the last 3 lines means, if it's not a regular file As for RewriteRule formats: So E.g. for Another key problem is that this indeed solve the question. Internally, (I
guess) it always need Btw, making an extra
By default, PHP platforms such as WordPress and Codeigniter append index.php at the end of website URL, which is not really required. Here are the steps to remove index.php from URL using .htaccess in Apache web server. You can use these steps to remove index.php from WordPress, Codeigniter and other PHP websites. We will basically redirect the index.php to URL without it. For that we will need mod_rewrite Apache module. Before proceeding further, please ensure that you have enabled mod_rewrite in Apache web server. Here are the steps to enable mod_rewrite in Apache. At the end of it, you will have created a .htaccess file for your website. 1. Open .htaccess fileOpen terminal and run the following commands to open .htaccess file. We have used the default file path of .htaccess file. You can change it as per your requirement. $ sudo vi /var/www/html/.htaccess 2. Remove index.php from URLAdd the following lines in .htaccess file.
Let us look at each line above. The first line enables mod_rewrite if it is not enabled already. The second line matches URLs that are not files. The third line matches URLs that are not directories. So we are looking to match URLs that are neither files nor directories. The last line means that if the two RewriteCond statements before it are matched for a URL, then it will be redirected to URL without index.php in it. 3. Restart Apache web serverRestart Apache server to apply changes $ sudo systemctl restart httpd Now if you open browser and visit http://your_domain_or_IP/index.php you will be redirected to http://your_domain_or_IP. Replace your_domain_or_IP with your domain or IP address. Similarly, if you visit URL like http://your_domain_or_IP/index.php/folder1/folder2 you will be redirected to http://your_domain_or_IP/folder1/folder2 Related posts:
Can I delete index php?To remove the “index. php” from your site's URLs, you will first need to make sure your server is set up to pass would-be 404 requests off to Craft's index. php file behind the scenes. If you're running Apache, you can do that by creating a redirect in your site's .
How do I remove a site index?php from WordPress, Codeigniter and other PHP websites.. How to Remove index. php from URL. We will basically redirect the index. ... . Open . htaccess file. ... . Remove index. php from URL. ... . Restart Apache web server. Restart Apache server to apply changes $ sudo systemctl restart httpd.. Why is index php in my WordPress URL?php appears in the URL might be because the structure of permalinks is not set properly in WordPress Settings. So to verify if the structure of permalinks is set properly, let's check the permalink tab in WordPress Dashboard.
How do I remove a php from a URL?How to Remove .. Open htaccess file. Open terminal and run the following command to open . htaccess file. ... . Remove . php extension from URL. ... . Restart Apache web server. Restart Apache server with following command $ sudo systemctl restart httpd.. |