954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

.htaccess redirects

Hello! Me, again...

Just did the includes in my html...which is now shtml. (I'm learning...)

I realized that I needed to REDIRECT the html queries to the appropriate shtml files.

Here is my .htaccess file:

# This file is placed in the ShoBag root directory

<Files *>
Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
Header set Expires: 0
Header set Pragma: no-cache
</Files>

DirectoryIndex default.shtml

Redirect /default.html /default.shtml
Redirect /about.html /about.shtml
Redirect /contact.html /contact.shtml
Redirect /privacy.html /privacy.shtml
Redirect /return.html /return.shtml
Redirect /site.html /site.shtml
Redirect /uniqconcepts.html /uniqconcepts.shtml
Redirect /index.html /default.shtml
Redirect /index.shtml /default.shtml

ErrorDocument 401 /Error401.shtml
ErrorDocument 403 /Error403.shtml
ErrorDocument 404 /Error404.shtml
ErrorDocument 500 /Error500.shtml


The header commands were put there by my hosting company. I'm guilty on all others.

My problem:

I have another domain (seblake.com) under the shobag directory. It appears that the REDIRECT in the shobag .htaccess "overflows" into all of the subdirectories. Here is the .htaccess I created for the seblake subdirectory:

# This file is placed in the seblake (Max-Tech) directory

<Files *>
Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
Header set Expires: 0
Header set Pragma: no-cache
</Files>

DirectoryIndex default.html

Redirect /default.shtml /default.html
Redirect /about.shtml /about.html
Redirect /contact.shtml /contact.html
Redirect /privacy.shtml /privacy.html
Redirect /site.shtml /site.html
Redirect /index.html /default.html
Redirect /index.shtml /default.html

ErrorDocument 401 /Error401.html
ErrorDocument 403 /Error403.html
ErrorDocument 404 /Error404.html
ErrorDocument 500 /Error500.html


I'm sure you can recognize the loop...it confuses my browser... ;)

Care to offer a solution?

Also, do I need the header lines in the seblake .htaccess file also?

As always, I thank you for your time and assistance!!

< Steve >

seblake
Light Poster
41 posts since Jun 2009
Reputation Points: 10
Solved Threads: 1
 

OK. I think I've got it!!!

I'm sure there's a way to clean it up and write it better. I'm all ears!!

# This file is placed in the ShoBag root directory

<Files *>
Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
Header set Expires: 0
Header set Pragma: no-cache
</Files>

<Files .htaccess>
order allow,deny
deny from all
</Files>

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^Botnames....
RewriteRule ^.* - [F,L] 

DirectoryIndex default.shtml

#  Same syntax per page
Redirect http://www.shobag.com/default.html http://www.shobag.com/default.shtml
Redirect http://www.shobag.com/index.html http://www.shobag.com/default.shtml
Redirect http://www.shobag.com/index.shtml http://www.shobag.com/default.shtml

ErrorDocument 401 http://www.shobag.com/Error401.shtml
ErrorDocument 403 http://www.shobag.com/Error403.shtml
ErrorDocument 404 http://www.shobag.com/Error404.shtml
ErrorDocument 500 http://www.shobag.com/Error500.shtml


And then, I had to make one for the sub-directory (another domain).

# This file is placed in the seblake (Max-Tech) "root" directory

<Files *>
Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
Header set Expires: 0
Header set Pragma: no-cache
</Files>

<Files .htaccess>
order allow,deny
deny from all
</Files>

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^Botnames....
RewriteRule ^.* - [F,L]

DirectoryIndex default.html

#  Same syntax per page
Redirect default.html  <a href="http://www.shobag.com/seblake/default.html">http://www.shobag.com/seblake/default.html</a> 
Redirect index.html  <a href="http://www.shobag.com/seblake/default.html">http://www.shobag.com/seblake/default.html</a> 
Redirect index.shtml  <a href="http://www.shobag.com/seblake/default.html">http://www.shobag.com/seblake/default.html</a> 

ErrorDocument 401  <a href="http://www.seblake.com/Error401.html">http://www.seblake.com/Error401.html</a> 
ErrorDocument 403  <a href="http://www.seblake.com/Error403.html">http://www.seblake.com/Error403.html</a> 
ErrorDocument 404  <a href="http://www.seblake.com/Error404.html">http://www.seblake.com/Error404.html</a> 
ErrorDocument 500  <a href="http://www.seblake.com/Error500.html">http://www.seblake.com/Error500.html</a>


It appears to work... But...is it correct? ;-)

Thank you!!!

< Steve >

seblake
Light Poster
41 posts since Jun 2009
Reputation Points: 10
Solved Threads: 1
 

Wanted to give you a heads up on the redirects. If for any reason you're hoping to see any of your pages appear in the Google index, then you might want to consider setting those redirects with 301s.

Example:
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Redirect 301 /oldpage2.html http://www.yoursite.com/folder/

Dish2u
Newbie Poster
4 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

301? Or is this just an ad....?

seblake
Light Poster
41 posts since Jun 2009
Reputation Points: 10
Solved Threads: 1
 

301 Blake.....if it's a permanent fix then it should always be 301

Dish2u
Newbie Poster
4 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

A permanent fix? Pardon my ignorance.... Does that mean if I am going to keep the 401 page that I created as part of my web site, then I should use 301 instead? Is it the same syntax, etc?
Google Index ignores 401s?
Thanks!

seblake
Light Poster
41 posts since Jun 2009
Reputation Points: 10
Solved Threads: 1
 

your primary efforts should be to minimize your crawl errors as much as possible, and one of the best ways to avoid it is through the usage of 301 redirects to a page that carries content worthy of placing in the index......ideally you want the googlebot to spider down through your content without running into a 4XX error which is like running into a brick wall......i would highly recommend that you set yourself up with google webmaster tools and measure your efforts through the crawl errors you see in there......btw, keep your 401 as your failsafe, but ultimately do what's needed through your 301 redirects to prevent your visitors from ending up there

Dish2u
Newbie Poster
4 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

I'll check it out. Appreciate the help. Thanks!

seblake
Light Poster
41 posts since Jun 2009
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: