Forum Moderators: phranque
Redirect 301 /index.html http://www.example.com/node
Redirect 301 /YWExcerptPage.html http://www.example.com/young-wizards-current-chapter-excerpt
Redirect 301 /YWMakeoverIntroToTheWorld.html http://www.example.com/About-The-Young-Wizards-Universe
Redirect 301 /YWWizardsHoliday.html http://www.example.com/Wizards-Holiday-Mass-Market-Edition
Redirect 301 /YWWizardsAtWar.html http://www.example.com/Wizards-At-War-Mass-Market-Edition
Redirect 301 /YWTheWizardsDilemma.html http://www.example.com/The-Wizards-Dilemma-Mass-Market-Edition
Redirect 301 /YWTheBooks.html http://www.example.com/the-books
...
All of these redirects are from files in the "public_html" root. Now, everything's working fine, and all the pages are redirecting correctly, except for one detail...
I have a subdomain, wcast.YW.net, where podcasts are kept. Because of some bandwidth issues, I don't want to move or redirect this subdomain / subdirectory to the .com side. I had thought that simply avoiding specifying it in the list above would mean that it wouldn't redirect. Nonetheless, it's redirecting to the "index" page of the other domain -- this URL:
http://www.example.com/node
Is that initial redirect of the old site's index.html to the YWCom "index" somehow to blame for this? Or is there something else going on that I don't know about / understand (because I'm very new at this)? Or have I screwed something up in some interesting way? And can someone suggest syntax by which I can stop the "wcast" subdomain from redirecting, and tell .htaccess that I do *not* want this subdirectory redirected, but logins to that URL should proceed as they have until now? (The subdomain is mapped to /wizcast, under the root.)
All advice gladly accepted.
Best -- Diane
[edited by: jdMorgan at 8:46 pm (utc) on Feb. 23, 2007]
[edit reason] Removed specifics per Terms of Service [/edit]
However, Apache mod_rewrite [httpd.apache.org] can be used to address this problem with a "long list" of redirects, using an "abort-on-match" code structure, or a "skip on match" structure, whichever you find easier to implement and maintain. The skip structure requires that you accurately count the rules to be skipped, while the abort structure and rules must be placed after any other rules which might apply to the current URL request -- Otherwise, they'll never be run for the subdomain.
Here are both methods (near the top) -- Use only one.
# Enable mod_rewrite
Options +FollowSymLinks
RewriteEngine on
#
# Stop mod_rewrite processing if "wcast" subdomain requested
RewriteCond %{HTTP_HOST} ^wcast\.example.net
RewriteRule .* - [L]
#
# Skip next seven rules if "wcast" subdomain requested
RewriteCond %{HTTP_HOST} ^wcast\.example.net
RewriteRule .* - [S=7]
#
RewriteRule ^index\.html$ http://www.example.com/node [R=301,L]
RewriteRule ^YWExcerptPage\.html$ http://www.example.com/young-wizards-current-chapter-excerpt [R=301,L]
RewriteRule ^YWMakeoverIntroToTheWorld\.html$ http://www.example.com/About-The-Young-Wizards-Universe [R=301,L]
RewriteRule ^YWWizardsHoliday\.html$ http://www.example.com/Wizards-Holiday-Mass-Market-Edition [R=301,L]
RewriteRule ^YWWizardsAtWar\.html$ http://www.example.com/Wizards-At-War-Mass-Market-Edition [R=301,L]
RewriteRule ^YWTheWizardsDilemma\.html$ http://www.example.com/The-Wizards-Dilemma-Mass-Market-Edition [R=301,L]
RewriteRule ^YWTheBooks\.html$ http://www.example.com/the-books
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
/home/user/domain.com
/home/user/sub.domain.com
/home/user/sub2.domain.com
The .htaccess file controls everything below it. So if you put it here:
/home/user/.htaccess
It's gonna affect all your subdomains.
But if you put it here:
/home/user/domain.com/.htaccess
Then it affects only domain.com.
Hope that helps.
Michael -- I wish my directory structure was as straightforward as yours: otherwise I wouldn't be having these problems. ;) What I have is this:
/
¦__ public_html
¦__ mail
¦__ imap
¦__ domains
"public_html" contains my web root, and the .htaccess. The various subdirectories are "below" it:
¦__ wzcast
¦__ cgi
¦__ images
¦__ email-username
...etc. However, the "domains" directory structure goes like this:
yw.net
¦__ public_html
¦__ logs
¦__ stats
¦__ private_html
¦__ public_ftp
¦__ .htpasswd
-- and the second "public_html" directory is identical to the first, containing my .htaccess file and everything else. There are no other domain/subdomain directories under "domains" except for the yw.net one.
So you see why I'm confused. I'm wondering whether perhaps I should be putting the .htaccess file "higher up", say in the domains directory. Yet the directory I'm trying to keep from being redirected is below "domains" as well, and should still be affected.
(sigh) Any thoughts?
Best -- Diane