Redirect to the root

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Redirect to the root

12 Dec 2012, 16:50

Hello all.

I am trying to redirect index.php and index.html to the root.

I've found the help on redirecting from non-www to www on this forum very useful, but the codes I found on the thread http://www.helicontech.com/forum/17801- ... _Root.html didn't work for my index.php redirect.

I don't know what version of ISAPI my hosting company, Titan, uses.

Can you please tell me what lines of code I need to add to my httpd.ini file to redirect index.php and index.html to the root?

Thank you.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect to the root

12 Dec 2012, 23:32

hello,

If you have httpd.INI, this means you have ISAPI_Rewrite 2. If you had httpd.CONF - of would have been ISAPI_Rewrite 3.
The code in the thread provided should work, just don't forget to add '[ISAPI_Rewrite]' in the befinning:

Code: Select all
[ISAPI_Rewrite]
RewriteRule ^/index\.php /index/.html [I,R]


You'd be able to find more examples for ISAPI_Rewrite 2 here

Regards
Andrew

User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Re: Redirect to the root

13 Dec 2012, 13:14

Thank you very much for your reply.

I tried the code you suggested, but what it does is redirect /index.php to /index/.html

What I am trying to do is redirect both index.php to the root and my old index.html to the root as well.

I suppose once I find the code that works for index.php, then I can just use it again modified for index.html, so the code I'm looking for does not need to perform both tasks at the same time.

Can you suggest the code for this?

Thank you again.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect to the root

13 Dec 2012, 14:03

My bad, I though you're redirecting php to html.

Code: Select all
[ISAPI_Rewrite]
RewriteRule ^/index\.php / [I,R]
RewriteRule ^/index\.html / [I,R]


Regards
Andrew

User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Re: Redirect to the root

13 Dec 2012, 14:47

Thank you.

I've tried the code and what happens now is that the browser cannot display the page if I type /index.php or /index.html

In fact I had already tried that, after your original code.

The code that worked to redirect from non-www to www was:

RewriteCond Host: (?!www\..*)(.+\.com)
RewriteRule (.*) http\://www.$1$2 [RP]

Based on that, does this give you an idea of what code could work for the current problem?

Thanks again.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect to the root

13 Dec 2012, 15:11

Please, specify

"I've tried the code and what happens now is that the browser cannot display the page if I type /index.php or /index.html"


Regards
Andrew

User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Re: Redirect to the root

13 Dec 2012, 15:58

If I type in my browser http://www.italytravelsguide.com/index.php or http://www.italytravelsguide.com/index.html, in both cases no page gets displayed, and I get the browser error message: "Internet Explorer cannot display the webpage ".

Please let me know if this answers your question and it's clear enough.

Thank you. Regards
Enza

User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Re: Redirect to the root

13 Dec 2012, 15:59

Not now because I've reverted to the previous code, I mean, to avoid the error message.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect to the root

13 Dec 2012, 16:24

Well,

Since, this one worked
Code: Select all
RewriteRule ^/index\.php /index/.html [I,R]

and this one doesn't
Code: Select all
RewriteRule ^/index\.php / [I,R]


I'm puzzled. And the error message you provided doesn't specify if it's 404 error or smth else.

Regards
Andrew

User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Re: Redirect to the root

13 Dec 2012, 20:58

You were right to try to analyze the error message, which Internet Explorer didn't.

It's a loop problem, apparently.

Firefox, Chrome and Safari all point to the fact that:
"Too many redirects occurred while trying to open the page.
"This might occur if you open a page that is redirected to open another page which then is redirected to open the original page".

I'm working on it, and I'll keep you posted.

You've been very helpful in pointing me to the recognition of the problem.


Thank you. Regards
Enza

User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Re: Redirect to the root

14 Dec 2012, 11:59

Hello.

I have achieved what I wanted, i.e. both /index.php and /index.html are redirected to the root / , but in order to do that I had to delete index.html from the server, although that page is redirected, so it doesn't show any 404 error message or other error message.

The reason why I had to delete it is because I couldn't find a code for redirecting /index.html to /index.php, and if I kept index.html, the old page corresponding to it showed when the root / was displayed, and not the new page index.php, and I didn't want that to happen.

I don't know if Google minds the deletion of a page if it is also redirected.

In any event, to be on the safe side and make things neater, do you know the code to redirect /index.html to /index.php in ISAPI_Rewrite 2?

Thank you again. Regards
Enza

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect to the root

14 Dec 2012, 21:32

Do I know the rule to redirect /index.html to /index.php?
I guess you were given a very similar rule in the beginning of this conversation. Or is it something else?

Regards
Andrew

User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Re: Redirect to the root

14 Dec 2012, 21:51

No, the code was for something different, namely redirecting index.php and index.html to the root.

Regards
Enza

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect to the root

14 Dec 2012, 22:05

There was a rule:

Code: Select all
[ISAPI_Rewrite]
RewriteRule ^/index\.php /index/.html [I,R]

and the responce was:

"I tried the code you suggested, but what it does is redirect /index.php to /index/.html"


So now it's going to be:
Code: Select all
RewriteRule ^/index\.html /index/.php [I,R]

User avatar
Posts: 9
Joined: 12 Dec 2012, 16:28

Re: Redirect to the root

21 Dec 2012, 19:31

That code, in either form, does not have any effect, I don't know why.

Anyway, I'm happy with the result I got, thank you very much for your help.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 54 guests