9

I was wondering if it is possible to remove the 'index.php' that is shown in every URL.

16

You can do that by enabling the SEF URLs and especially the parameter "Use URL rewriting" in the Joomla global configuration.

Please note that this will generate an internal server error if you didn't create the .htaccess file before enabling the option.

There is a doc page explaining what steps are needed to get those nice URLs. Have a look here: http://docs.joomla.org/Enabling_Search_Engine_Friendly_(SEF)_URLs

Basically you have to rename the htaccess.txt file found in your Joomla root directory. Depending on your hoster, additional steps are needed.

  • OK, I will give that a try. It's a bit weird that Joomla doesn't generate that code itself as now I think about it. I think I tried that option and it did in fact crash. – connersz May 12 '14 at 8:09
  • 1
    That's exactly the reason why Joomla doesn't generate the code itself. It depends a lot on the host and we don't want to completely break your site by enabling a feature :) – Bakual May 12 '14 at 12:48
4

You could add this code to the top of Joomla's index.php:

if(strcmp($_SERVER['REQUEST_URI'], '/index.php') == 0 && $_SERVER['QUERY_STRING'] == ''){
    header("HTTP/1.1 301 Moved Permanently");
    header('Location: /');
    exit;
}

Be careful though, if you take this approach, you'll need to redo this when you upgrade.

  • I'd suggest you could do this as an optional hack if the redirect and ReWrite did not work in htaccess. So a valid fall back – tristanbailey May 9 '14 at 1:08
  • agreed. that's actually how we got to this solution. We couldn't get the htaccess fix to work properly site wide – ContextSwitch May 9 '14 at 12:57
4
  1. Changed htaccess.txt to .htaccess
  2. Site > Global Configuration : Use URL rewriting (Choose Yes)
  3. SEO Settings Search Engine Friendly URLs(Choose Yes)
2

Here is a general method if your site crashes using .htaccess:

  • You should comment one or both of these lines:

Options +FollowSymLinks

and/or,

RewriteBase /

This should work fine! Note: you do commenting by giving a hashtag for a line "#"

0

If you're using the nginx web-server, then you can use the following snippet for the nginx.conf configuration file where your Joomla! site is served from (basically, just add the if-condition after any existing lines where the index index.php directive appears).

#https://stackoverflow.com/a/38165768/remove-index-php-from-joomla-urls-with-nginx
index index.php index.html index.htm;
if ($request_uri ~ "^/(.*)(?<=/)index\.php/?((?<=/).*)?$") {    return  301 /$1$2;  }

More details are at https://stackoverflow.com/questions/28997028/remove-index-php-from-joomla-urls-with-nginx/38165768#38165768.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.