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
- - - - -

Htaccess Redirect 301 Page Redirects Not Working...please Help


  • Please log in to reply
11 replies to this topic

#1 SteveVeach

SteveVeach

    HR 1

  • Members
  • Pip
  • 6 posts
  • Location:Chicago, Illinois USA

Posted 18 October 2012 - 12:39 AM

I'm a novice but don't see what I'm doing wrong with what would appear to be very simple page by page redirects for pages that have changed names but have identical content.

This is an example of the top section of the file with an example page redirect line:

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{http_host} ^clarityperformanceallianceDOTcom [nc]
RewriteRule ^(.*)$ ThisIsWhereIPutTheFullURL/$1 [r=301,nc]

Redirect 301 /clarity/[A].html ThisIsWhereIPutTheFullURL/current-performance.html

I realize that the old page is a very poorly named page (because of the brackets) but the brackets are not why it's failing. I've tried this line with other pages that don't have brackets in their names and they fail as well.

I'm on a shared Network Solutions Linux server using what I assume is an Apache server. They have their shared servers set up in what I assume is pretty typical in that my root folder is called htdocs and I can create as many subfolders and websites within them as I want to, hence why I have a subfolder named "clarity" for this particular website.

The global non-www to www redirect works perfectly. It's all the individual page redirects where I changed the page names that aren't working.

What am I missing?

Thanks a lot in advance!

#2 chrishirst

chrishirst

    A not so moderate moderator.

  • Moderator
  • 7,108 posts
  • Location:Blackpool UK

Posted 18 October 2012 - 09:14 AM

What am I missing?


Dunno

I'm trying to figure out what this~:
RewriteCond %{http_host} ^clarityperformanceallianceDOTcom [nc]
RewriteRule ^(.*)$ ThisIsWhereIPutTheFullURL/$1 [r=301,nc]
Is supposed to actually do
clarityperformancealliance.com IS what HTTP_HOST will contain, if that is the hostname that is being requested.


I realize that the old page is a very poorly named page (because of the brackets) but the brackets are not why it's failing. I've tried this line with other pages that don't have brackets in their names and they fail as well.

Do we actually get to SEE what the URI looks like? And of course the canonical URI you want to redirect to.

#3 SteveVeach

SteveVeach

    HR 1

  • Members
  • Pip
  • 6 posts
  • Location:Chicago, Illinois USA

Posted 18 October 2012 - 01:38 PM

Dunno

I'm trying to figure out what this~:

RewriteCond %{http_host} ^clarityperformanceallianceDOTcom [nc]
RewriteRule ^(.*)$ ThisIsWhereIPutTheFullURL/$1 [r=301,nc]
Is supposed to actually do
clarityperformancealliance.com IS what HTTP_HOST will contain, if that is the hostname that is being requested.



Do we actually get to SEE what the URI looks like? And of course the canonical URI you want to redirect to.


I'm sorry but the EXTREMELY restrictive rules and moderation of this forum would not allow me to put full URLs in posts so I had to figure out a way to post my question and allow it to go through. You can trust that I have the actual lines of code formatted correctly. I just don't understand why the 301 redirect lines aren't working at all in the same htaccess file.

#4 Jill

Jill

    Recovering SEO

  • Admin
  • 33,009 posts

Posted 18 October 2012 - 03:16 PM

Regarding the moderation problem, you can put it in the way you have it for real when you use the [ code ] markup. But it would be best for your own good to use "example.com" rather than your actual website.

#5 SteveVeach

SteveVeach

    HR 1

  • Members
  • Pip
  • 6 posts
  • Location:Chicago, Illinois USA

Posted 18 October 2012 - 09:57 PM

OK, I'll try this again using the Admin's suggestion and hope that it works. This is an example of my htaccess file with just one of the many redirect 301 lines I'll need in the final file:

This is an example of the top section of the file with an example page redirect line:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^example.com [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]
Redirect 301 /subfolder/oldpagename.html http://www.example/newpagename.html

So the first 4 lines are working fine and doing a 301 redirect from the non-www to the www URL for the entire site.

It's the individual redirect 301 line that isn't working. I don't get an error, just no redirection.

#6 Ron Carnell

Ron Carnell

    HR 6

  • Moderator
  • 966 posts
  • Location:Michigan USA

Posted 19 October 2012 - 06:29 AM

This is just a guess, Steve, but are you actually pointing your browser to http://www.example.com/subfolder/oldpagename.html in hopes of triggering the redirect?

Or are you, perhaps, pointing your browser to http://subfolder.com/oldpagename.html ?

In other words, if you are creating new domains WITHIN your hosted domain, your code should treat them as domains not as subfolders. The first step in that direction would be for /subfolder (if it is, indeed, a domain) to have its own copy of .htaccess, one that addresses it by domain and not by folder name. Does that make sense at all?

If that still doesn't help, my suggestion would be to temporarily remove everything from .htaccess except the one line you feel isn't working. If it still doesn't work, you know you have a syntax problem. If it, instead, starts working, you know you have a conflict with other code. If the latter, start putting back in the code one line at a time until it breaks again.
  • SteveVeach likes this

#7 SteveVeach

SteveVeach

    HR 1

  • Members
  • Pip
  • 6 posts
  • Location:Chicago, Illinois USA

Posted 19 October 2012 - 12:26 PM

Thanks you SO much for responding Ron.

I have certainly tried removing the other lines and just putting the single line redirect and still no joy. I’m not sure I fully understand your response so please allow me to provide some very specific information that I hope will clarify things.

I have multiple websites created on my shared server Network Solutions account, which obviously is a Linux server running Apache (not sure of the version). They provide a simple pointer redirection tool in their control panel that allows one to point any domain to any folder on one’s account. My account’s root folder on their server is called htdocs. Since I have multiple sites under this account, I’ve created a subfolder for each one with no sites being stored within the htdocs root folder itself:

/htdocs/site1
/htdocs/site2
/htdocs/site3
/htdocs/site4

In their control panel, I have options to point domain names to folders and have done so as such:

http://site1.com					 /htdocs/
http://www.site1.com			 /htdocs/site1

They do not use htaccess files by default but allow one to create their own. Thus I have created the one I mentioned in this post to do a proper 301 redirect for the non-www to the www version and it’s working. My htaccess file is located in the root htdocs folder.

Of course, now I need 301 redirects for all the individual pages within each website that I am planning on changing names for and that’s what’s not working so far. I’m sure it’s something simple that I’m just overlooking.

Thanks again Ron for your help.

#8 chrishirst

chrishirst

    A not so moderate moderator.

  • Moderator
  • 7,108 posts
  • Location:Blackpool UK

Posted 19 October 2012 - 02:25 PM

Be aware that with a physical directory setup as yours is, the .htaccess in the "root" htdocs directory is going to affect ALL websites that branch off the htdocs directory.

#9 Ron Carnell

Ron Carnell

    HR 6

  • Moderator
  • 966 posts
  • Location:Michigan USA

Posted 19 October 2012 - 03:05 PM

I suspected that might be the case, Steve. Just for clarification, let's recap.

The folder /htdocs contains a subfolder /htdocs/site1, which contains all the files for site1.com. To view those files in your browser, you point the Location to http://www.site1.com. Is that correct so far?

You have a disk file at /htdocs/site1/oldpagename.html that can be viewed in a browser at http://www.site1.com/oldpagename.html. You want to redirect visitors who view that file (as distinct from reaching it on disk) to http://www.site1.com/newpagename.html. We still on the same page?

I'm going to further assume that your host is using Apache to assign /htdocs/site1/ as the Document Root for the domain site1.com. There are other possibilities, but this is probably a best-guess.

Let's look at the line that isn't working for you (with a slight change to the domain, just to be consistent):

Redirect 301 /site1/oldpagename.html http://www.site1.com/newpagename.html

Apache's redirect directive is used to map an old URL-path to a new URL. I think your problem, Steve, is that you're asking it to map a disk path (which is what /subfolder/ is) to an URL. Another way to look at it: if a browser won't understand http://www.site1.com/site1/oldpagename.html, then Apache's redirect isn't going to understand it either.

If all of my guesses are right, the solution is simple.

Create an .htaccess file in /htdocs/site1/ (you may have to abandon the safely of your control panel to do it) with one line (at least to start):

Redirect 301 /oldpagename.html http://www.site1.com/newpagename.html

Let us know, Steve, if that works for you ...
  • SteveVeach likes this

#10 SteveVeach

SteveVeach

    HR 1

  • Members
  • Pip
  • 6 posts
  • Location:Chicago, Illinois USA

Posted 19 October 2012 - 07:33 PM

Be aware that with a physical directory setup as yours is, the .htaccess in the "root" htdocs directory is going to affect ALL websites that branch off the htdocs directory.

Yes, thank you...I'm aware of that and it's fine.

#11 SteveVeach

SteveVeach

    HR 1

  • Members
  • Pip
  • 6 posts
  • Location:Chicago, Illinois USA

Posted 19 October 2012 - 07:50 PM

omg Ron...it worked! I can't believe I couldn't figure this out. I thought I tried every possible permutation of syntax but obviously not. :D I can't thank you enough. I thought it might be something simple I was missing. AWESOME. You've not only helped me but a friend of mine that has tons of page names to change. I'm going to call him tonight and tell him!

Take care.

#12 Ron Carnell

Ron Carnell

    HR 6

  • Moderator
  • 966 posts
  • Location:Michigan USA

Posted 20 October 2012 - 05:41 AM

:)




1 user(s) are reading this topic

0 members, 1 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!