Forum Moderators: phranque

Message Too Old, No Replies

Problem with index.php 301 redirect to root but keep the rest of the p

redirect index.php to root and keep path

         

Treondecember

4:41 am on Aug 10, 2010 (gmt 0)

10+ Year Member



Hi Guys,

I am unfortunately a total htaccess noob, ive been reading and reading for the last few days but have not found a solution for my problem. Im using Joomla for my site and i always had the index.php in all my links. When i installed sh404sef to make SEF links this index.php was removed. Now i have 590 404errors in my webmaster tools.
Here is an example of the link
Before: www.example.com/index.php/en/mycontent
After: www.example.com/en/mycontent

As far as i understood i need to use htaccess to redirect all links, i had no luck however doing this so far and my google ranking is dying fast :(

Any help would be appreciated.
Regards
Roman

[edited by: jdMorgan at 12:35 pm (utc) on Aug 10, 2010]
[edit reason] example.com [/edit]

jdMorgan

12:49 pm on Aug 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put this rule *ahead* of the block(s) of code that have already been inserted in .htaccess by the SEF plug-in and Joomla. If any of the first two lines are duplicated in either the SEF or Joomla code, you may delete those duplicates.

Options +FollowSymLinks -MultiViews
RewriteEngine on
#
# Externally redirect direct client requests to remove "index.php/" from initial URL-path-part
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
RewriteRule ^index\.php(/(.*))?$ http://www.example.com/$2 [R=301,L]

Typical plug-in and Joomla .htaccess code is highly inefficient. Once you get your main problem fixed, you may want to look at some of the other threads here to find information on how to slightly modify your SEF/Joomla .htaccess code to noticeably speed up your site.

Jim

Treondecember

4:26 pm on Aug 12, 2010 (gmt 0)

10+ Year Member



Hey Jim,

many many thanks, your a life saver.
I added your code and it worked like a charm.

Many thanks much appreciated.

Regards

jdMorgan

5:02 pm on Aug 12, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do look into the previous threads on optimizing the Joomla and plug-in .htaccess code. You can easily double the speed of some of that code and avoid an early server upgrade...

Jim

Treondecember

8:11 am on Aug 14, 2010 (gmt 0)

10+ Year Member



hi Jim,

I just found that the code creates a problem in virtuemart.
When adding to cart the page redirects to the homepage and doesnt add to cart :( i removed the code for now.

regards
Roman

jdMorgan

11:53 am on Aug 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well that code will likely need to be tweaked for your specific URL-set, but do remember the concept.

That modification wasn't written and proposed based just on "theory." It was written because it fixed a server that had become very slow slow and unresponsive, causing customers to flee. Using that technique improved performance significantly, and avoided an early (and expensive) server upgrade.

There's no such thing as "copy-and-paste" server config code -- In almost every case, *something* is different and needs to be tweaked or adjusted or re-coded. That speed-up code works for Joomla -- But I have no experience with VirtueMart or any of its requirements as regards URLs, and the code therefore likely does not address them.

Anyway, what matters is that you understand that the out-of-the-box rewrite-to-Joomla and rewrite-to-WordPress code is very inefficient because it does many, many unnecessary disk reads, and that these disk checks can in fact be avoided with a little bit of work on that code, resulting in faster server responses, fewer disk accesses, lower power consumption, less heat, and therefore, happier customers and longer disk life.

Jim

Treondecember

12:21 pm on Aug 14, 2010 (gmt 0)

10+ Year Member



can i hire you to fix this ? :)