I posted this issue on the drupal forums but alas, have not gotten any response. Hopefully some of you local folks can help out.
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 (FYI: I've removed all the hash marks because they caused a style change so that all the comments were about 20px high. Code with hash marks seems to display properly at my original post: http://drupal.org/node/405122)
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?
Comments
RE: need help with redirects
I'm new to Drupal, so perhaps there is something I'm missing and if so, please correct me. I'm not certain why there are so many RewriteCond when typically what would be needed is a simple RewriteRule for each item. Is a docroot typically defined for Drupal, like a standard website?
e.g.
Instead of:
RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^contact.php$ "http:\/\/mysite.com\/contact" [R=301,L]
This should work fine: RewriteRule ^contact.php$ /contact [R,L]
I would suspect all the RewriteCond are stepping on each other in the current set up.
Hope this helps.
I'm likewise pretty baffled
I'm likewise pretty baffled by the array of rewrite conditions in your .htaccess file. If all you've done is moved your core files to docroot from a drupal subdirectory I would imagine that something along the lines of
RewriteRule ^/drupal/$ "/$1" [R,L] would pretty much take care of everything in one fell swoop. Perhaps I'm not understanding the problem?
Two things going on
There are two things going on:
One is that I moved the files from the /drupal subdirectory to the main directory.
icatriangle.org/drupal redirects just fine to icatriangle.org.
icatriangle.org/drupal/calendar, on the other hand, does not redirect to icatriangle.org/calendar.
But the other is that there was a site in existence in that main directory prior to building the new site in drupal...and that site had pages with similar, but not identical, content. So, the original site had a page called icatriangle.org/programs.php, which listed events. The equivalent page on the new (current) site is icatriangle.org/calendar.
If this isn't painfully obvious already, I'm a designer whose UNIX experience is limited to a night class I took in the early 90s. About all I remember is pwd, ls and cd. :-/
Moving Drupal root
The best way of dealing with a change in the Drupal root is to change the apache stanza that point to it. No modifications to .htaccess are necessary nor desired.
URL Change plus Simplification
I think Claire wants to redirect because she's changing the actual URLs and wants old bookmarks / search engine results / etc. to work correctly. The .htaccess redirects are usually the way we do that.
Another simplification would be to remove the OR conditions entirely and just always redirect no-www to www (or vice versa). That may also help with SEO, so you don't have to tell google what the preferred domain is, etc.
Those generated redirects are completely baffling to me, the whole thing should really just be done with a single redirect that strips the /drupal/ out of the path.
Ken Winters
www.coalmarch.com
Ken Winters
Not quite getting it
Tried some of your suggestions, but nothing seems to be working, and this is beyond my technical skill set.
I am looking for a drupal developer that I can work on a regular basis who can handle issues like this as well as php, jquery, theme and module development. I any of you are interested, let me know.
I might be interested. My
I might be interested. My availability for side projects fluctuates pretty wildly though based on what I've got going on at work. In the mean time can you paste a complete copy of your .htaccess file so we can take a closer look?
htaccess file
I posted the complete file at http://drupal.org/node/405122; I've also attached it to this post (with a .txt extension to allow it to upload).
the actual site is icatriangle.org
I've deleted all except for the one working redirect for now.
I also posted more info about my developer need in the jobs section.
Wish I could make it to the meetups, especially hack night, but our ICA Triangle meetings are on the same night. :-(