Page 1 of 4

How to Remove index.php from urls

Posted: Wed Apr 20, 2011 12:44 pm
by rehan3690
Hello friends

I am using Joomla 1.6(JA Methys 1.6 from joomlart)

Problem is every link has index.php like http://www.mysite.com/index.php/contact

http://www.mysite.com/index.php/about-us

how do i remove these .../index.php/.... from my urls



My SEO setting under Golbal Configuration are

==================================
Search Engine Friendly URLs Yes

Use Apache mod_rewrite Yes

Adds Suffix to URL No

Unicode Aliases No

Include Site Name in Page Titles No
==================================

I have changed htaccess.txt to .htaccess

I have tried every thing but unable to remove index.php in urls

Please help me

My apologies if this exists eslewhere

Thanks in advance

Re: How to Remove index.php from urls

Posted: Fri Apr 29, 2011 4:54 am
by hanjimail
Hi. there!

Go to global configuration page.
Set Yes to URL rewriting.

That will remove index.php.

But, you have done this already. Its problem may be in .htaccess
or your server set-up.

Have you checked Joomla 1.6 required server environments?

PHP 5.2+
MySQL 5.0.4+
Apache 2.x+

Re: How to Remove index.php from urls

Posted: Fri Apr 29, 2011 8:17 am
by g1smd
Once you have it working, you will need to add a redirect to your .htaccess file such that if URLs with index.php continue to be requested by users following old links in SERPs and in bookmarks they are redirected to the new URL without it.

Code: Select all

RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php/([^\ ]*)\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php/(.*)$ http%2://www.example.com/$1$2 [R=301,L]
I urge you to use the new .htaccess file that comes with Joomla 1.5.23 onwards and Joomla 1.6.2 onwards. Look for the file called htaccess.txt in the installer package. It contains a note showing exactly where the redirects should go (in addition to a number of other changes). Add your new redirect code in the file at the point it says "redirects go here", or similar.

You might also want to add this code too:

Code: Select all

########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
########## End - 301 Redirect

Re: How to Remove index.php from urls

Posted: Tue May 31, 2011 7:03 am
by sitehost
Are you using a Windows server?? if so you must have Mod rewrite.. but the server wont control what joomla renders...

Make sure your web.config.txt is renamed to web.config if your on a IIS server or that your htaccess.txt is .htaccess

And then Change your configuration settings to normal and then save, and retry your SEO Settings

Search Engine Friendly URLs are ON
Use URL rewriting is ON


let me know when you get it working.. if its doesnt let me know and ill take a look.

Bret

Re: How to Remove index.php from urls

Posted: Tue May 31, 2011 7:49 am
by g1smd
To clear up the confusing post above.

Use .htaccess if your server uses Apache.

Use web.config if your server uses IIS.

Re: How to Remove index.php from urls

Posted: Fri Jun 03, 2011 11:27 am
by RealJames
I realize this is late, but for anyone finding this thread in google, like I just did, I found a real simple way to solve the OP's problem!

put this in your .htaccess file

Code: Select all

RedirectMatch 301 ^/index.php/(.*)$ http://www.domain.com/$1
don't forget to change www.domain.com to your own domain!

Re: How to Remove index.php from urls

Posted: Fri Jun 03, 2011 9:17 pm
by g1smd
RealJames wrote:Put this in your .htaccess file

Code: Select all

RedirectMatch 301 ^/index.php/(.*)$ http://www.domain.com/$1
don't forget to change http://www.domain.com to your own domain!
For many reasons you should not use RedirectMatch in the same .htaccess file as any RewriteRule directives. This code should be used:

Code: Select all

RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php/([^\ ]*)\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php/(.*)$ http%2://www.example.com/$1$2 [R=301,L]

Re: How to Remove index.php from urls

Posted: Mon Jun 13, 2011 7:27 pm
by g1smd
The canonical URL for the site root is http://www.example.com/ with a trailing slash and without index filename.

Re: How to Remove index.php from urls

Posted: Sun Jun 19, 2011 4:04 pm
by busybee2345
Hi

I also have the same problem removing the index.php from URLs. The use SEO-friendly URL and URL re-write options are enabled on joomla global configuration.

Apache version 2.2.16
PHP version 5.2.14
MySQL version 5.0.91-community
Joomla 1.6.3 mod_rewrite enabled by hosting company so we can access our own .htaccess files.

.htaccess file is ammended with the base URL
RewriteBase /~username/subdirectory

I have done this because the joomla installation is in a subdirectory. When I click a link to load a page the URL is re-written without the index.php/ but the page is not loaded and an error message informing of website maintenance appears instead. If I change the subdirectory path in .htaccess to anything else I get internal server error500 if I try to access any page.

Please help!

Re: How to Remove index.php from urls

Posted: Sun Jun 19, 2011 11:59 pm
by g1smd
When I click a link to load a page the URL is re-written without the index.php/
To be absolutely clear, do you see URLs without index.php in the browser status bar when you mouseover the on-page link without clicking it?

URL rewriting starts by publishing the right URL in the link on the page. It is too late to change the URL after the link is clicked.

Is the .htaccess file located at example.com/.htaccess or at example.com/folder/.htaccess here?

Re: How to Remove index.php from urls

Posted: Mon Jun 20, 2011 12:57 pm
by busybee2345
Hi, great to get your reply

URL

From the homepage when I click on a menu link to a sublevel page the re-written URL is shown correctly in the status bar of the browser e.g.

mysite.com/contact

However the page is not loaded, unless I go in and alter the URL to include /index.php/ when it works just fine.

.HTACCESS

.htaccess file I am ammending is located in the subfolder of the joomla installation - i.e. in

subfolder.myhostingdomain.com

where mysite.com is my domain name that maps to the subfolder above.

Hope that's a bit clearer!

Re: How to Remove index.php from urls

Posted: Mon Jun 20, 2011 1:26 pm
by g1smd
From the homepage when I click on a menu link to a sub-level page the re-written URL is shown correctly in the status bar of the browser.
That wasn't the question. The question is:
To be absolutely clear, do you see URLs without index.php in the browser status bar (that's the one at the bottom of the window) when you mouseover the on-page link without clicking it?

Re: How to Remove index.php from urls

Posted: Tue Jun 21, 2011 5:43 pm
by busybee2345
g1smd wrote:
From the homepage when I click on a menu link to a sub-level page the re-written URL is shown correctly in the status bar of the browser.
That wasn't the question. The question is:
To be absolutely clear, do you see URLs without index.php in the browser status bar (that's the one at the bottom of the window) when you mouseover the on-page link without clicking it?
Yes it shows correctly if you mouse over or click. But the page does not load.

Re: How to Remove index.php from urls

Posted: Wed Jun 22, 2011 6:15 am
by g1smd
The .htaccess file is not being read because it is in the wrong folder, or the RewriteBase value in the .htaccess file is incorrect.

Alternatively, the $livesite variable (in configuration.php) has the wrong value. It may even be a combination of those things.

Re: How to Remove index.php from urls

Posted: Wed Jun 22, 2011 1:24 pm
by vseprav
just need to activate mod_rewrite in .htaccess file

Re: How to Remove index.php from urls

Posted: Fri Jun 24, 2011 10:17 pm
by busybee2345
Thanks for your replies.

What should the 'livesite' variable be? The domain name people use to access the site or the physical location?

With the .htaccess file Base rewrite, if I change the path to anything other than the physical location the error is 'Internal Server Error' rather than the better error message I wrote for when a page can not be loaded. So I think it is the correct path? The URL is re-written but the page can not be loaded (apart from the homepage of course).

Re: How to Remove index.php from urls

Posted: Fri Jun 24, 2011 10:53 pm
by busybee2345
Update: well I've managed to find a solution - I basically just commented out the base rewrite rule and tried it with the .htaccess and it worked! Didn't need base rewrite or livesite after all.

Thanks everyone :-)

Re: How to Remove index.php from urls

Posted: Wed Jun 29, 2011 11:21 am
by jawaune
Guys I am a little confused about renaming the htaccess.txt file. All files have extentions. Am I going to be renaming it to .htaccess without the .txt extension or is it going to be .htaccess.txt. I already tried chanting it to .htaccess without the .txt extension then changing my mod rewrite from no to yes and it didn't work. I experienced the same problem as the guy above. my home page would show but my other pages wouldn't. So is it supposed to be .htaccess.txt or just .htaccess? Because if it's just .htaccess without any extension, that sounds a little wierd to me.

Re: How to Remove index.php from urls

Posted: Thu Jun 30, 2011 7:18 pm
by g1smd
Filenames beginning with a period are system files. The name you need is exactly ".htaccess".

The file is distributed as "htaccess.txt" to make it easier to open in a standard text editor.

Re: How to Remove index.php from urls

Posted: Sat Jul 23, 2011 6:58 am
by rehan3690
thnx to every one my problem got fixed

i enabled rewrite_module in apache modules

edited the code in .htaccess

thk u very much

Re: How to Remove index.php from urls

Posted: Mon Jul 25, 2011 9:11 pm
by g1smd
If Google has already indexed URLs with /index.php/ in them, you need a redirect to tell them that they need to de-index those URLs and index the new ones.

However, never mix RedirectMatch and RewriteRule directives in the same site. Use RewriteRule for all of your rules.

Code: Select all

RewriteRule ^index\.php/(.+)$ http://www.example.com/$1 [R=301,L]
Placement of this rule with respect to other rules (i.e. rule ordring) is very important.

Re: How to Remove index.php from urls

Posted: Fri Oct 21, 2011 8:46 am
by idemodalje
Hi guys,

I really hate this /index.php/

I set:
Search Engine Friendly URLs ON
Use URL rewriting ON

I changed htaccess.txt to .htaccess and I get correct url in browsers but also 404 page.

Please help :(

Re: How to Remove index.php from urls

Posted: Sun Oct 30, 2011 11:53 pm
by riprod
Simple solution is add this to the .htaccess file

RewriteBase /.

Don't forget the . after the /
worked for me on Rackspace cloud

Re: How to Remove index.php from urls

Posted: Wed Nov 02, 2011 9:49 am
by idemodalje
Sorry guys, I made a mistake. ;)

It works great, with this to steps:

1) edit htaccess.txt to .htaccess
2) turn on seo in Joomla backend

thanks!

Re: How to Remove index.php from urls

Posted: Sat Nov 12, 2011 1:26 am
by g1smd
3) Set up a redirect so that requests for the old URL are redirected to the new URL. This forces searchengines to update the listings for your site, and retains the traffic to your site while the old URLs are still indexed and ranking.

Re: How to Remove index.php from urls

Posted: Mon Jan 16, 2012 2:51 pm
by Shai
Hi everyone,

I'm still stumped by this and cannot remove it from our site, I've tried enabling SEO and apache rewrite,. I've even renamed the htaccess file and still no joy.

I've tried to redirect as well and still no joy, it keeps coming up with a 404 error.

Does anyone have any idea at all what it could be?

Thanks

Re: How to Remove index.php from urls

Posted: Tue Jan 17, 2012 6:31 am
by velf
g1smd wrote:Once you have it working, you will need to add a redirect to your .htaccess file such that if URLs with index.php continue to be requested by users following old links in SERPs and in bookmarks they are redirected to the new URL without it.

Code: Select all

RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php/([^\ ]*)\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php/(.*)$ http%2://www.example.com/$1$2 [R=301,L]
I urge you to use the new .htaccess file that comes with Joomla 1.5.23 onwards and Joomla 1.6.2 onwards. Look for the file called htaccess.txt in the installer package. It contains a note showing exactly where the redirects should go (in addition to a number of other changes). Add your new redirect code in the file at the point it says "redirects go here", or similar.

You might also want to add this code too:

Code: Select all

########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
########## End - 301 Redirect
thanks. it work

Re: How to Remove index.php from urls

Posted: Mon Jan 23, 2012 1:05 pm
by adamlisit
Took me out happy to read this comment. You are really blow job, things are happen in the world elegant nice post. Thanks for sharing the knowledge.

Re: How to Remove index.php from urls

Posted: Wed Jan 25, 2012 7:45 am
by ellare
so in my case....

in my .htaccess file i have 1000+ rewriteRules for SEO/SERP because a site has been redesigned and moved to new server...

well... now here's what's happening.

{{Joomla 1.7 site}}

with URL Rewriting on - the site does not work. None of the navigation main menu links work.

with URL Rewriting OFF - site works great but has ugly index.php in all URLs

this is an example of the 1000+ rewrite rules I have in my .htaccess

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=107&Itemid=193
RewriteRule ^index\.php$ http://www.thesitenamehere.org? [R=301,L]

with URL Rewriting on - mousing over link shows the correct URL structure - like http://www.thesitenamehere.org/news-events

but clicking on the nav menu link does nothing

config file shows live_site at http://www.thesitenamehere.org

mod_rewrite is on and enabled because it was all working beautifully before I did the 1000+ rewrites.

I think my error is in my rewrites / .htaccess file some how.

adding these bits to .htaccess made NO urls work - whether or not URL Rewriting was on or off - nothing worked

########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.sitenamehere.org/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.sitenamehere.org/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.sitenamehere\.org)?$
RewriteRule (.*) http://www.sitenamehere.org/$1 [R=301,L]
#
########## End - 301 Redirect

what kind of Redirect/Rewrite .htaccess monster have I created here??!?!

thanks


************ UPDATE

I cleared my browser's cache and everything is now working correctly. With URL Rewriting on, redirects are working. SEF are good.

working fine in FF8 and IE8

Re: How to Remove index.php from urls

Posted: Sat Feb 18, 2012 6:22 am
by swhiteIN
I have successfully removed the index.php from my URLs (I think) but I am having trouble with the re-directs I think - here is what happens:

When I insert the following suggested code in the designated area on the .htaccess file whenever I go to an old link it simply takes me to the homepage rather than to the "new" non-index.php version of the page:

Code:
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php/([^\ ]*)\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php/(.*)$ http%2://www.example.com/$1$2 [R=301,L]

If I instead enter the following code - it no longer takes me to the homepage but seems to not be doing a redirect as index.php remains in the URL. Also both the index.php and "new" non-index.php pages get picked up in a sitemap search when using the following code:

Code:
########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
########## End - 301 Redirect

Can someone point to what is wrong here and which code is preferred and why I might be getting these anomalies with each? I don't want to send Google on a wild goose chase - SEO is very important. Thanks!