EllisLab text mark
Advanced Search
     
301 Redirect
Posted: 03 July 2012 12:12 PM   [ Ignore ]
Joined: 2009-12-10
40 posts

An SEO company has requested I provide 301 redirects for a site I worked on, but when I input the URl information the browser can’t complete the task. More specifically they want the mydomain/index.asp, mydomain/index.cfm, .html, .htm, etc. to redirect to http://www.mydomain.com .

This is what Firefox tells me - Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Does this have something to do with rewriting the .htaccess file for EE? Is there anyway to correct this?

Thanks

 
Posted: 03 July 2012 02:21 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-06-12
149 posts

Hi Stuart,

What version of EE are you using?

Are you removing the index.php using .htaccess?

Thank you,

Mike

 
Posted: 03 July 2012 02:39 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2009-12-10
40 posts

Version 2.

Yes I’m removing the index.php using .htaccess. I’ve tried two separate methods:

<IfModule mod_rewrite.c
RewriteEngine On 
# Removes index.php 
RewriteCond $!\.(gif|jpe?g|png)$ [NC] 
RewriteCond 
%{REQUEST_FILENAME} !-
RewriteCond 
%{REQUEST_FILENAME} !-
RewriteRule 
^(.*)$ /index.php/$1 [L] 
# If 404s, "No Input File" or every URL returns the same thing 
# make it /index.php?/$1 above (add the question mark)
 
</IfModule

and

RewriteEngine on
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
$!^(system|themes|index\.php|admin\.php).*
RewriteRule ^(.*)$ /index.php?/$1 [NC,L] RewriteCond %{HTTP_HOST} ^mydomain.com[OR] 

the remainder of the file looks similar to this for each index.aspx, index.htm, etc:

RewriteCond %{HTTP_HOST} ^mydomain\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^index\.asp"http\:\/\/www\.mydomain\.com\/" [R=301,L] 

Thanks

 
Posted: 03 July 2012 02:41 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2009-08-28
253 posts

This problem cannot be troubleshot if you don’t include the full contents of your .htaccess file.

 Signature 

@NickBenson | Senior Front End Developer at PressEnter | Twin Cities ExpressionEngine User Group | EE Pro Network Member

 
Posted: 03 July 2012 02:51 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2009-12-10
40 posts
RewriteEngine on
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
$!^(system|themes|index\.php|admin\.php).*
RewriteRule ^(.*)$ /index.php?/$1 [NC,L] RewriteCond %{HTTP_HOST} ^mydomain.com[OR]

AddType video
/ogg .ogv
RewriteCond 
%{HTTP_HOST} ^mydomain\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^/?$ "http\:\/\/www\.mydomain\.com\/" [R=301,L]

RewriteCond 
%{HTTP_HOST} ^mydomain.com\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain.com\.com$
RewriteRule ^index\.php"http\:\/\/www\.mydomain.com\.com\/" [R=301,L]

RewriteCond 
%{HTTP_HOST} ^mydomain.com\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain.com\.com$
RewriteRule ^index\.htm"http\:\/\/www\.mydomain.com\.com\/" [R=301,L]

RewriteCond 
%{HTTP_HOST} ^mydomain.com\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain.com\.com$
RewriteRule ^index\.html"http\:\/\/www\.mydomain.com\.com\/" [R=301,L]

RewriteCond 
%{HTTP_HOST} ^mydomain.com\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain.com\.com$
RewriteRule ^index\.shtml"http\:\/\/www\.mydomain.com\.com\/" [R=301,L]

RewriteCond 
%{HTTP_HOST} ^mydomain\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^index\.asp"http\:\/\/www\.mydomain\.com\/" [R=301,L]

RewriteCond 
%{HTTP_HOST} ^mydomain.com\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain.com\.com$
RewriteRule ^index\.aspx"http\:\/\/www\.mydomain.com\.com\/" [R=301,L]

RewriteCond 
%{HTTP_HOST} ^mydomain.com\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain.com\.com$
RewriteRule ^index\.cfm"http\:\/\/www\.mydomain.com\.com\/" [R=301,L]

RewriteCond 
%{HTTP_HOST} ^mydomain.com\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain.com\.com$
RewriteRule ^index\.pl"http\:\/\/www\.mydomain.com\.com\/" [R=301,L] 
 
Posted: 03 July 2012 03:18 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2009-08-28
253 posts
RewriteCond %{HTTP_HOST} ^mydomain\.com[OR]
RewriteCond 
%{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^/?$ "http\:\/\/www\.mydomain\.com\/" [R=301,L] 

You’re stuck in a loop because this rule says “if the address ends in a slash, redirect to mydomain.com/.” As such, it’s going over and over and over again…

My suggestion would be re-writing your rules with this syntax:

Redirect 301 /path/on/old/site.html /path/to/new/page

You can then add other rules that will remove or add the trailing slash, and remove or add the www, depending on your preferences.

 Signature 

@NickBenson | Senior Front End Developer at PressEnter | Twin Cities ExpressionEngine User Group | EE Pro Network Member

 
Posted: 03 July 2012 03:30 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2011-11-30
20 posts

See, if you go to mydomain.com/test, it will be redirected to mydomain.com/index.php/test, then to http://www.mydomain.com/test which, is something EE doesn’t understand.

EE only understand mydomain.com index.php/test, which should be redirected from mydomain.com/test

To solve this, the index.php removal code should be in the end, and put all your SEO redirection code before it.

Besides, you have piles of same codes for SEO redirection, what’s the point of that?

It’s better to give specific requirements for redirection if the list is not long, say index.cfm, index.asp etc.

Besides, if the site don’t have such URLs before, it make no sense to redirect them because nobody will reach them, including search engines.

 

 
Posted: 03 July 2012 03:55 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2009-12-10
40 posts

pixelbaker

Moving the index.php removal code worked.

Thanks