homepage Welcome to WebmasterWorld Guest from 54.234.60.133
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Need help fixing our drupal .hta file
Site is accessible via IP
Future




msg:4548936
 10:36 am on Feb 26, 2013 (gmt 0)

Hello,
Our 3rd experience with India's leading Drupal company went for a toss !
Our site/portal revamped on drupal (still with 1000s of problems) is massively indexed with IP Address in SERPs.
This has made us loose entire PR across portal.

I tried to use an old code, given by JDMorgan in 2006 on webmasterworld, but it is not working.
Please check and help.


########################################
#http://www.mydomain.in/.htaccess#
########################################
ErrorDocument 400 /
ErrorDocument 401 /
ErrorDocument 403 /
ErrorDocument 404 /
#

Using your home page for error-handling may result in problems, especially if you pass all 403, 404, and 410 errors to the home page. This has the potential to create massive duplicate-content problems with your site, and allow someone to ruin your rankings by linking to bad URLs on your site. I recommend that you remove the 400 and 401 ErrorDocument directives completely, and then create appropriae error pages for 403, 404, and 410 errors.

#
Options +Indexes +FollowSymlinks
RewriteEngine on
RewriteBase /
#
# Prevent duplicate content on gallery and forums subdomain
RewriteCond %{HTTP_HOST} ^(gallery¦forums)\.mydomain.in
RewriteRule ^(gallery¦forums)(.*)$ [%{HTTP_HOST}$1...] [R=301,L]
#
#Re-Direct users coming to forums and gallery via IP Address in SERPs index to proper location
RewriteCond %{HTTP_HOST} ^000\.000\.000\.000
RewriteRule ^(gallery¦forums)/(.*)$ [$1.mydomain.in...] [R=301,L]
#
#Re-Direct users coming to Site via IP Adress to proper location
RewriteCond %{HTTP_HOST} ^(000\.000\.000\.000¦mydomain\.in)
RewriteRule (.*) [mydomain.in...] [R=301,L]
########################################


At present we do not have issue with forums and gallery.
But I am using entire above code, replacing required values

Regards,

 

Future




msg:4548937
 10:43 am on Feb 26, 2013 (gmt 0)

This is our existing .hta file

########################################
#http://www.mydomain.in/.htaccess#
########################################
#
Options +Indexes +FollowSymlinks
RewriteEngine on
RewriteBase /
#
# Prevent duplicate content on gallery and forums subdomain
RewriteCond %{HTTP_HOST} ^(gallery¦forums)\.mydomain.in
RewriteRule ^(gallery¦forums)(.*)$ [%{HTTP_HOST}$1...] [R=301,L]
#
#Re-Direct users coming to forums and gallery via IP Address in SERPs index to proper location
RewriteCond %{HTTP_HOST} ^000\.000\.000\.000
RewriteRule ^(gallery¦forums)/(.*)$ [$1.mydomain.in...] [R=301,L]
#
#Re-Direct users coming to Site via IP Adress to proper location
RewriteCond %{HTTP_HOST} ^(000\.000\.000\.000¦mydomain\.in)
RewriteRule (.*) [mydomain.in...] [R=301,L]
########################################

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
Order allow,deny
</FilesMatch>

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
# There is no end quote below, for compatibility with Apache 1.3.
ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On

# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600

<FilesMatch \.php$>
# Do not allow PHP scripts to be cached unless they explicitly send cache
# headers themselves. Otherwise all scripts would have to overwrite the
# headers set by mod_expires if they want another caching behavior. This may
# fail if an error occurs early in the bootstrap process, and it may cause
# problems if a non-Drupal PHP file is installed in a subdirectory.
ExpiresActive Off
</FilesMatch>
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^send/([0-9]+)-(.) /send/send_node/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)/sendupdate/(.*) node/37425
RewriteRule blog/page-(.*)$ node&page=$1
RewriteRule (.*)/page(.*).htm$ $1&page=$2




# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^mydomain\.in$ [NC]
RewriteRule ^(.*)$ [mydomain.in...] [L,R=301]

#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /


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

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
# RewriteRule /index.php / [QSA]
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.90.2.5 2010/02/02 07:25:22 dries Exp $



#AuthType Basic
#AuthName "Test site"
#AuthUserFile "/home/techdup1/.htpasswds/public_html/passwd"
#require valid-user

lucy24




msg:4549195
 9:08 pm on Feb 26, 2013 (gmt 0)

Some random stuff, possibly overlapping anyone who comes along later and types faster than me

# Prevent duplicate content on gallery and forums subdomain
RewriteCond %{HTTP_HOST} ^(gallery|forums)\.mydomain.in
RewriteRule ^(gallery|forums)(.*)$ http:/ /%{HTTP_HOST}$1 [R=301,L]

wtf?!
You've got a rule that
#1 says it's to prevent Duplicate Content but instead preserves duplicate content by retaining the original hostname instead of redirecting to a canonical form
#2 reuses the part it was supposed to throw away --the (gallery|forums) bit-- and throws away the part it was supposed to reuse. Was this a typo?

I assume that the intention-- in English-- is this:

#1 If someone asks for an URL whose path begins /forums or /gallery, then dump that piece of the URL and redirect to

forums.example.com/
or
gallery.example.com/

plus the part of the path, if any, that came after /forums or /gallery regardless of what form they originally used for the (sub)domain name (that's the part of your existing rule that is missing)

#2 If someone asks for something in the (forums|gallery) subdomains but they don't get the hostname exactly right, then redirect to exactly

forums.example.com
or
gallery.example.com

plus requested path.

#3 If the request did not contain the words "forums" or "gallery" -- either as the beginning of the path or as a subdomain -- but the hostname isn't in the exact form

www.example.com

(or example.in or whatever your canonical name is) then redirect.

If that's right, then we can hammer out the best possible wording for the rules. Or at least cut-and-paste them from the best possible place, because yours is of course not the only drupal site around ;)

<Files favicon.ico>

Is there some arcane drupal-specific reason that sites don't have a favicon? This is the second time in two or three days that I've seen this identical code.

<IfModule mod_rewrite.c>

Any envelope in the form <IfModule blahblah is boilerplate that came with the distribution. Once you're on a specific site, dump it. You've either got the module or you haven't; code accordingly.

<IfModule mod_rewrite.c>
RewriteEngine on

And wtf? again. Now you're combining rules from two different sources, which can be lethal. I can tell because you've got earlier RewriteRules that aren't inside this envelope. All rewrites need to be collected in the same place and arranged in the order you want them to execute. Normally that means top to bottom, unless you've got RewriteRules inside a <Files> or <FilesMatch> envelope.

phranque




msg:4549318
 4:20 am on Feb 27, 2013 (gmt 0)

i would carefully study the WebmasterWorld thread linked below and perhaps you will find the solution you need.

Drupal .htaccess file:
http://www.webmasterworld.com/apache/4217718.htm [webmasterworld.com]

Future




msg:4549330
 5:20 am on Feb 27, 2013 (gmt 0)

lucy,phranque,
Thank You for stepping by, .hta stuff goes over my head completely

Will you be able to fix/correct the mistakes in above .hta ?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved