Forum Moderators: phranque

Message Too Old, No Replies

redirect all index.php to root except admin login

         

sixeleven

6:52 pm on Jul 27, 2008 (gmt 0)

10+ Year Member



hi
i have redirected my website url "index.php" to root by ,adding this peaces of code to my .htaccess

example.com/index.php to example.com

Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ [domain.com...] [R=301,L]

but this ,code also forward ,my login url ,and this cause problem to me to enter my website's admin

the url of admin is :

example.com/administrator/index.php

how i can ,define a code in .htaccess ,that it forward all the index.php url to root except /administrator/ directory.

nick279

9:55 pm on Jul 27, 2008 (gmt 0)

10+ Year Member



If you can't find a way to get this working effectivley, it may save you time entering code into the index.php file


if($_SERVER['REQUEST_URI'] == "/index.php")
{
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: /');
}

jdMorgan

10:28 pm on Jul 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add this to your existing rule:

RewriteCond $1 !^administrator/

For more information, see the references cited in our Forum Charter.

Jim

g1smd

10:42 pm on Jul 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Set up another RewriteCond that says to process the rule only if the folder is not the admin folder.

The not is done with a ! as the prefix.

[The perils of opening more than a dozen tabs and then reading and replying some time later.]

sixeleven

7:17 am on Jul 28, 2008 (gmt 0)

10+ Year Member



tanx alot for your responds

just another Question

how i can redirect all files to index.php except my home page?

i mean if some one try my home page url

example.com

it wont redirect to

example.com/index.php

but the other none index.php urls forward to index.php