1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect index.php to root for the whole website

Discussion in 'Black Hat SEO' started by mahamad3, Dec 31, 2013.

  1. mahamad3

    mahamad3 Regular Member

    Joined:
    Apr 26, 2012
    Messages:
    313
    Likes Received:
    26
    Location:
    Cairo
    Hi

    I need to redirect from index.php to the root

    I am using the following :

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?|php)\ HTTP/
    RewriteCond %{REQUEST_URI} !^/administrator/
    RewriteRule (([^/]+/)*)index\.(html?|php)$ http://www.example.com/$1 [R=301,L]

    but that's working only with the home page.

    for example if I open : www.mysite.com/index.php It's redirect to www.mysite.com

    but If I open : www.mysite.com/index.php/page1 it doesn't redirect

    I am using this part (RewriteCond %{REQUEST_URI} !^/administrator/) because it's a Joomla website, and If I don't use it I can't log in to the back end.
     
  2. tahworld

    tahworld Regular Member

    Joined:
    Aug 16, 2013
    Messages:
    457
    Likes Received:
    393
    Location:
    ✔✔✔✔✔✔✔
    Not sure if I understand your description of what you need, but if you mean what I think you mean, then:

    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !/administrator$
    RewriteRule .? /http://www.mysite.com [R=301,L]
     
    Last edited: Dec 31, 2013
  3. mahamad3

    mahamad3 Regular Member

    Joined:
    Apr 26, 2012
    Messages:
    313
    Likes Received:
    26
    Location:
    Cairo
    Thanks, but this code didn't work for me.


    but I found the solution.

    I used this code

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?|php)\ HTTP/
    RewriteCond %{REQUEST_URI} !^/administrator/
    RewriteRule (([^/]+/)*)index\.(html?|php)$ http://www.example.com/$1 [R=301,L]

    Then I used Redirect 301 for every page in the Main Menu.

    Internal pages under every menu item, redirect automatically if you redirect the main menu items.