Forum Moderators: phranque

Message Too Old, No Replies

Help with 301 redirect anyone?

         

stubbsy

11:39 am on Aug 22, 2005 (gmt 0)

10+ Year Member



Hi there,

I have recently had the misfortune to get banned from google for having duplicate content (I think). Anyway, to clean things up I've set up a 301 redirect from the site which had similar content on it to the site which I wanted to keep.

The problem is that I can no longer access the control panel for the old site as I now get redirected to the other site.

Is there anyway I can redirect all traffic from the site except for anyone trying to access the admin folder?

Thanks in advance

stubbsy

jdMorgan

1:41 pm on Aug 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post your current code so we can discuss it.

Generally, if you're using mod_rewrite to implement the redirect, you'd use a RewriteCond directive to create an exclusion for the /admin folder, so that the redirection is bypassed for that case.

Jim

stubbsy

2:30 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



Hi there,

all I did to acheive the redirect was to add this line of code to the current htaccess file

redirect 301 / http://www.example.com/

kind regards

stubbsy

the full htaccess reads this ....


# $Id: .htaccess,v 1.3 2003/06/12 10:53:20 hpdl Exp $
#
# This is used with Apache WebServers
#
# For this to work, you must include the parameter 'Options' to
# the AllowOverride configuration
#
# Example:
#
# <Directory "/usr/local/apache/htdocs">
# AllowOverride Options
# </Directory>
#
# 'All' with also work. (This configuration is in the
# apache/conf/httpd.conf file)

# The following makes adjustments to the SSL protocol for Internet
# Explorer browsers

<IfModule mod_setenvif.c>
<IfDefine SSL>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</IfDefine>
</IfModule>

# Fix certain PHP values
# (commented out by default to prevent errors occuring on certain
# servers)

#<IfModule mod_php4.c>
# php_value session.use_trans_sid 0
# php_value register_globals 1
#</IfModule>

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}

Options All -Indexes

redirect 301 / http://www.example.com/

[edited by: jdMorgan at 4:34 pm (utc) on Aug. 22, 2005]
[edit reason] Removed specifics per TOS. [/edit]

jdMorgan

4:45 pm on Aug 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since you appear to already be using mod_rewrite, just add a new rule. This replaces everything after the final </ifmodule> in the code you posted above.

You will need to insert the ful local URL-path to your control panel subdirectory in the RewriteCond line as shown.

Note that I took the liberty of cleaning up your other rules so that they will run a lot faster. However, since the domain rewrite rule is invoked first, those rules won't run, and you can safely delete them *after* and *if* you get the domain rewrite working. You may be able to use the technique shown for the rewrites on your 'real' domain.


Options All -Indexes
#
RewriteEngine On
RewriteBase /
#
RewriteCond %{REQUEST_URI} !^/local_path_to_your_control_panel
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
RewriteRule ^([^-]+)-p-([^.]+)\.html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^([^-]+)-c-([^.]+)\.html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^([^-]+)-m-([^.]+)\.html$ index.php?manufacturers_id=$2&%{QUERY_STRING}

Jim

stubbsy

7:48 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



Thanks very much for your help Jim and sorry about the links in my post but I found I couldn't edit them out once i'd submitted the post.

Thanks again :)

stubbsy

stubbsy

8:08 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



Hi Jim,

Sorry to trouble you again but I can't appear to get the rewritecond to work. I'm have tried everything i can think of any just geet a 404.

For the rewritecond line I have tried a number of things, the control panel is in the admin folder in the root of that domain.

The full path is

RewriteCond %{REQUEST_URI}!^/home/stubbsy/public_html/example/admin/

Is that what I should have in there?

The http addy would be http://www.example.com/admin/index.php

Thanks again for your time

stubbsy

jdMorgan

8:45 pm on Aug 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably, you need:

RewriteCond %{REQUEST_URI} !^/admin/

Remember, this should be a local URL-path {REQUEST_URI}, not a filepath.

Jim

stubbsy

7:49 am on Aug 23, 2005 (gmt 0)

10+ Year Member



Thanks very much, I'm not sure what the problem was but I had to delete the htaccess completely and then start again. It now works fine :)

Thanks again for your help - much appreciated

stubbsy