Sometimes you want to remove the /index.php from after your domain name or the category ID/article ID from your Category Blog or Category List menu items.
This blog post will explain how to do both.
Removing index.php from URLs
By default, Search Engine Friendly URLs are set to display domainname.com/index.php/whatever-else. It’s simple enough to remove index.php with just a few steps. You will need FTP or access to the hosting control panel to complete this task. We’ll be using cPanel in this example but it will be similar with any hosting dashboard.
- login to your cPanel hosting account dashboard or control panel
- click on File Manager
- click on public_html (Or whatever directory your site is in. In our case, it’s a subdomain named staging.)
- scroll down until you see the file named htaccess.txt
- right click on the file name
- rename file to .htaccess
- delete the .txt from the end (To be clear, you’re adding a . (dot) to the front and removing the . (dot) plus txt from the back of the file name.)
- click the Rename File button
- login to the backend of your Joomla site
- click on System -> Global Configuration
On the right-hand side of the screen, you’ll see the heading SEO Settings. The second field/setting is called Use URL Rewriting.
- toggle Use URL Rewriting from No to Yes.
- click Save & Close in the Top Toolbar
- go to the frontend of your website to the home page if you’re not there already (simply refresh the page if already on home page)
- Test the URLs by navigating to different pages and verifying that the index.php portion of the URL no longer displays
Note: Any hard URLs that have been used will no longer work. Any links you set in modules or particles or articles that included /index.php/whatever-else will need to be changed to simply /whatever-else without the index.php.
Removing the Category and Article IDs from URLs
In Category Blog or Category List Menu Item Types, the links will include either or both the Category ID and/or Article ID in the URL by default.
Thanks to excellent work by Hannes, there is now the option to change to the Modern Routing option and eliminate those category/article IDs from the URL. Here’s how to do it.
NOTE FOR NEW SITES ONLY: Do this only on new sites or test it on a dev site before doing it on a live site as your links will break. You want to make sure everything works as intended BEFORE doing this on a live site since all your links will need to change and multiple redirects will likely need to be done. If it’s a brand new install, you’re safe to change the setting to Modern. Here’s the Joomla tooltip warning saying the same thing.
- login to the backend of Joomla
- go to Content -> Articles
- click the Options button on the far right in the Top Toolbar
- click on the Integration tab
- change the URL Routing field from Legacy to Modern under the heading Routing
- change Remove IDs from URLs from No to Yes.
- click Save & Close
On the frontend of your website,
- navigate to the home page if you’re not there already (simply refresh the page if already on home page)
- navigate to one of your Category Blog or Category List menu item types
- test several to verify the IDs are not displaying in the URLs
Your URL should look like the below in which the 3 that was in our URL before is no longer displaying.
Thanks for following along! Great work.
Don’t miss all the Joomla classes and tutorials on OST.