How to Remove index.php from urls
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Wed Apr 20, 2011 11:29 am
How to Remove index.php from urls
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
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
-
- Joomla! Enthusiast
- Posts: 221
- Joined: Sat May 31, 2008 12:15 am
- Location: Yokohama, Japan
- Contact:
Re: How to Remove index.php from urls
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+
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+
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
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.
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
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]
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
Online since 1995.
-
- Joomla! Apprentice
- Posts: 33
- Joined: Sun Feb 24, 2008 5:22 am
Re: How to Remove index.php from urls
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
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
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
To clear up the confusing post above.
Use .htaccess if your server uses Apache.
Use web.config if your server uses IIS.
Use .htaccess if your server uses Apache.
Use web.config if your server uses IIS.
Online since 1995.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Fri Jun 03, 2011 11:03 am
- Location: 神戸 三宮
- Contact:
Re: How to Remove index.php from urls
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
don't forget to change www.domain.com to your own domain!
put this in your .htaccess file
Code: Select all
RedirectMatch 301 ^/index.php/(.*)$ http://www.domain.com/$1
www.realizeenglish.com - The Joomla site I manage
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
For many reasons you should not use RedirectMatch in the same .htaccess file as any RewriteRule directives. This code should be used:RealJames wrote:Put this in your .htaccess filedon't forget to change http://www.domain.com to your own domain!Code: Select all
RedirectMatch 301 ^/index.php/(.*)$ http://www.domain.com/$1
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]
Online since 1995.
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
The canonical URL for the site root is http://www.example.com/ with a trailing slash and without index filename.
Online since 1995.
-
- Joomla! Apprentice
- Posts: 19
- Joined: Mon May 30, 2011 7:23 pm
Re: How to Remove index.php from urls
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!
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!
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
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?When I click a link to load a page the URL is re-written without the index.php/
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?
Online since 1995.
-
- Joomla! Apprentice
- Posts: 19
- Joined: Mon May 30, 2011 7:23 pm
Re: How to Remove index.php from urls
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!
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!
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
That wasn't the question. The question is: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.
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?
Online since 1995.
-
- Joomla! Apprentice
- Posts: 19
- Joined: Mon May 30, 2011 7:23 pm
Re: How to Remove index.php from urls
Yes it shows correctly if you mouse over or click. But the page does not load.g1smd wrote:That wasn't the question. The question is: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.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?
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
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.
Alternatively, the $livesite variable (in configuration.php) has the wrong value. It may even be a combination of those things.
Online since 1995.
- vseprav
- Joomla! Apprentice
- Posts: 35
- Joined: Mon Jun 20, 2011 2:23 pm
- Location: Ukraine, Lviv
- Contact:
Re: How to Remove index.php from urls
just need to activate mod_rewrite in .htaccess file
-
- Joomla! Apprentice
- Posts: 19
- Joined: Mon May 30, 2011 7:23 pm
Re: How to Remove index.php from urls
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).
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).
-
- Joomla! Apprentice
- Posts: 19
- Joined: Mon May 30, 2011 7:23 pm
Re: How to Remove index.php from urls
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 :-)
Thanks everyone :-)
-
- Joomla! Apprentice
- Posts: 24
- Joined: Sat Jun 18, 2011 11:00 am
Re: How to Remove index.php from urls
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.
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
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.
The file is distributed as "htaccess.txt" to make it easier to open in a standard text editor.
Online since 1995.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Wed Apr 20, 2011 11:29 am
Re: How to Remove index.php from urls
thnx to every one my problem got fixed
i enabled rewrite_module in apache modules
edited the code in .htaccess
thk u very much
i enabled rewrite_module in apache modules
edited the code in .htaccess
thk u very much
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
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.
Placement of this rule with respect to other rules (i.e. rule ordring) is very important.
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]
Online since 1995.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Wed Feb 17, 2010 8:48 am
Re: How to Remove index.php from urls
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
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
-
- Joomla! Apprentice
- Posts: 34
- Joined: Sun May 23, 2010 11:25 pm
Re: How to Remove index.php from urls
Simple solution is add this to the .htaccess file
RewriteBase /.
Don't forget the . after the /
worked for me on Rackspace cloud
RewriteBase /.
Don't forget the . after the /
worked for me on Rackspace cloud
-
- Joomla! Apprentice
- Posts: 14
- Joined: Wed Feb 17, 2010 8:48 am
Re: How to Remove index.php from urls
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!
It works great, with this to steps:
1) edit htaccess.txt to .htaccess
2) turn on seo in Joomla backend
thanks!
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: How to Remove index.php from urls
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.
Online since 1995.
-
- Joomla! Fledgling
- Posts: 1
- Joined: Mon Jan 16, 2012 2:48 pm
Re: How to Remove index.php from urls
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
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
-
- Joomla! Fledgling
- Posts: 1
- Joined: Tue Jan 17, 2012 6:21 am
- Contact:
Re: How to Remove index.php from urls
thanks. it workg1smd 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.
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.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]
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
-
- Joomla! Fledgling
- Posts: 3
- Joined: Mon Jan 23, 2012 12:58 pm
Re: How to Remove index.php from urls
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.
-
- Joomla! Apprentice
- Posts: 42
- Joined: Sat Feb 24, 2007 11:27 pm
Re: How to Remove index.php from urls
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
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
-
- Joomla! Fledgling
- Posts: 2
- Joined: Sat Feb 18, 2012 6:14 am
Re: How to Remove index.php from urls
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!
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!