Standard caveat: I'm a designer, not a programmer or sysadmin, so the answer to this may be obvious to some but I'm afraid I'm at a loss for how to fix it.

I recently moved my site from a /drupal subdirectory to the site root. Using cPanel's "redirect" dialog, I redirected mysite.com/drupal ==> mysite.com. I also set a wildcard so that, for example, mysite.com/drupal/news would redirect to mysite.com/news. In addition, I set some redirects for pages from the former site to the equivalent pages on the new site, e.g., mysite.com/hire.php ==> mysite.com/jobs.

The basic mysite.com/drupal ==> mysite.com is working, but none of the others are. I sent a support ticket to the (budget) webhost who replied "your drupal .htaccess has so many redirects in it its causing things not to work." Looking at the .htaccess file, I see this:

# Various rewrite rules.

RewriteEngine on

# 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]
#
# 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 /

# 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?q=$1 [L,QSA]

followed by what appears to be the rewrite rules written by cPanel:

# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $
RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^drupal\/?(.*)$ "http\:\/\/mysite\.com\/$1" [R=301,L]

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

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

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

RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^find\.php$ "http\:\/\/mysite\.com\/member\-directory" [R=301,L]

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

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

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

Is this a simple matter of cutting and pasting cPanel's rewrites into the IfModule section? Or is something more elaborate required?

Thanks in advance for any recommendations.

Comments

kalilo’s picture

Im facing now the same problem, any ideas to fix this ?

seanray’s picture

Put the drupal redirect setting to be below cPanel setting. It should work.

watergate’s picture

Thanks, simple but effective