Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Efficient Redirect For Index*.htm*


  • Please log in to reply
2 replies to this topic

#1 etzeppy

etzeppy

    HR 2

  • Active Members
  • PipPip
  • 37 posts

Posted 31 December 2010 - 09:45 AM

I just replaced an html site with php and I am working on redirects. The original site was a mess with frames, etc. I have the following RewriteRule working to redirect specific requests for index.html to the root:

CODE
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ <A href="http://mydomain.com/">http://mydomain.com/</A> [R=301,L]

However, I also need to redirect index1.htm and index2.htm to the root. Is there a RewriteRule that would redirect all three (index.html, index1.htm, & index2.htm) so I can do this more efficiently?

I actually have several other files (i.e. main.htm, brochures.html, etc) that also need to redirect to the root but I am assuming I will need separate rules for those.

Edited by etzeppy, 31 December 2010 - 10:13 AM.


#2 Mhoram

Mhoram

    HR 4

  • Active Members
  • PipPipPipPip
  • 114 posts
  • Location:Quincy, Illinois, USA

Posted 05 January 2011 - 06:33 PM

QUOTE(etzeppy @ Dec 31 2010, 08:45 AM) View Post
CODE
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ <A href="http://mydomain.com/">http://mydomain.com/</A> [R=301,L]

That rule works? Can't say I've ever seen a RewriteRule with HTML tags in it before.

Anyway, it doesn't sound like you need the overhead of mod_rewrite here. Just use simple Redirects:

CODE
Redirect permanent index.html http://mydomain.com/
Redirect permanent index2.htm http://mydomain.com/

and so on.

#3 etzeppy

etzeppy

    HR 2

  • Active Members
  • PipPip
  • 37 posts

Posted 06 January 2011 - 12:08 PM

QUOTE(Mhoram @ Jan 5 2011, 05:33 PM) View Post
That rule works? Can't say I've ever seen a RewriteRule with HTML tags in it before.

Anyway, it doesn't sound like you need the overhead of mod_rewrite here. Just use simple Redirects:

CODE
Redirect permanent index.html http://mydomain.com/
Redirect permanent index2.htm http://mydomain.com/

and so on.


It does indeed work...well I see your point. The interface converted the destination URL to html when I copied it in but I did not notice. The <A href="http://mydomain.com/"> should not be there. Here is the corrected code:

CODE
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ mydomain.com [R=301,L]


The idea was to only redirect specific requests for index.html (old bookmarks for example) to the root without rewriting the URL to the new index.php file. I did not want to replace an old bookmark and indexing problem with a new one. I don't really understand the rule. I just found it online and it seems to do what I want.

I am using simple 301 redirects for other pages and they are working. I just thought it might be more efficient to somehow add the additional index* redirects into the conditions of that existing RewriteRule. However, I am okay with what I have. It works.

Edited by etzeppy, 06 January 2011 - 04:07 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

SPAM FREE FORUM!
 
If you are just registering to spam,
don't bother. You will be wasting your
time as your spam will never see the
light of day!