Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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.

share|improve this answer
    
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

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.

share|improve this answer
    
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
  1. Changed htaccess.txt to .htaccess
  2. Site > Global Configuration : Use URL rewriting (Choose Yes)
  3. SEO Settings Search Engine Friendly URLs(Choose Yes)
share|improve this answer

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 "#"

share|improve this answer

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).

#http://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 http://stackoverflow.com/questions/28997028/remove-index-php-from-joomla-urls-with-nginx/38165768#38165768.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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