jdMorgan

msg:4179531 | 1:09 am on Jul 31, 2010 (gmt 0) |
Change "olddomain" in your existing rules to "newdomain." Put your new "catch-all" domain redirect rule ahead of your last rule -- that is, this new redirect will be the last external redirect, and then your last rule does internal rewrites only. Jim
|
mkingsle

msg:4180604 | 2:37 pm on Aug 2, 2010 (gmt 0) |
Thanks for the help JD. You are always of great service. Does this rule look correct, by the way? RewriteCond %{HTTP_HOST} olddomain.com [NC] RewriteCond (.*) [newdomain.com] [R=301,L] RewriteRule (.*) [newdomain.com...] [R=301,L] or should I use: RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ [newexample.com...] [R=301,L] or can I skip the RewriteCond statements all together and just use: RewriteRule (.*) [newdomain.com...] [R=301,L] or RewriteRule ^(.∗)$ [newdomain.com...] [R=301,L] Seems like there are several ways to slice this onion. Thanks in advance.
|
jdMorgan

msg:4180849 | 11:25 pm on Aug 2, 2010 (gmt 0) |
All are flawed in one way or another. Try:
# Externally redirect all requests for non-blank non-canonical hostnames to canonical hostname RewriteCond %{HTTP_HOST} ^!(newdomain\.com)?$ RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
Jim
|
mkingsle

msg:4185067 | 8:55 pm on Aug 10, 2010 (gmt 0) |
This is what I have thus far: DefaultType application/x-httpd-php AddHandler x-httpd-php .php4 Options +FollowSymLinks RewriteEngine on RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php?\ HTTP/ [NC] RewriteRule ^(.*)index.php?$ [newsite.com...] [R=301,L] RewriteCond %{HTTP_HOST} ^newsite\.com RewriteRule ^(.*)$ [newsite.com...] [R=permanent,L] RewriteCond %{HTTP_HOST} !^www\.newsite\.com RewriteRule (.*) [newsite.com...] [R=301,L] rewriterule ^ama/([A-Za-z0-9]+)$ /includes/amazon.php?id=$1 Which lines are you saying i should replace with the following: # Externally redirect all requests for non-blank non-canonical hostnames to canonical hostname RewriteCond %{HTTP_HOST} ^!(newsite\.com)?$ RewriteRule ^(.*)$ [newsite...] [R=301,L] Thanks Jim
|
jdMorgan

msg:4185137 | 1:18 am on Aug 11, 2010 (gmt 0) |
It should look like this:
DefaultType application/x-httpd-php AddHandler x-httpd-php .php4 # Options +FollowSymLinks RewriteEngine on # # Externally redirect direct client requests for "/index.php" or # "/index.php4" in any subdirectory to "/" in that same directory RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/\ ]+/)*index\.php4?\ HTTP/ [NC] RewriteRule ^(([^/]+/)*)index\.php4?$ http://newsite.com/$1 [R=301,L] # # Externally redirect all requests for non-blank non-canonical hostnames to canonical hostname RewriteCond %{HTTP_HOST} !^(newsite\.com)?$ RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L] # # Internally rewrite "/ama/<id>" URL requests to amazon script filepath, passing <id> value in query string RewriteRule ^ama/([A-Za-z0-9]+)$ /includes/amazon.php?id=$1
Note the comments. They are every bit as important as the code. If these comments don't say exactly what you want to do, then the code is wrong... Jim
|
mkingsle

msg:4187788 | 4:07 pm on Aug 16, 2010 (gmt 0) |
Thanks for the help Jim. I had one last question. It seems that you left out one of the condition/rules that I had in my .htaccess: RewriteCond %{HTTP_HOST} ^newsite\.com RewriteRule ^(.*)$ [newsite.com...] [R=permanent,L] Was this because it was redundant and therefore combined with another in your final solution? Honestly, I can't remember what the above does. p.s. I've learned a valuable lesson for further websites...always use comments.
|
mkingsle

msg:4187798 | 4:15 pm on Aug 16, 2010 (gmt 0) |
Hi again Jim. I got an error when using your solution: Firefox has detected that the server is redirecting the request for this address in a way that will never complete. Thanks in advance.
|
g1smd

msg:4187971 | 9:51 pm on Aug 16, 2010 (gmt 0) |
The final rule needs an [L] flagged added for sure. The missing rule appears to be catered for in other code. Check the code carefully, do you want the www included or omitted in your target URL?
|
mkingsle

msg:4188247 | 2:08 pm on Aug 17, 2010 (gmt 0) |
Hi Jim: Basically what I want in my code is the following: # Redirect direct client requests for /index.php in any directory to "/" in that directory # Redirect direct client requests to remove .php extensions # Redirect all non-blank non-canonical hostname requests to canonical hostname # Redirect to new website from old website # Redirect the /ama urls to the amazon.php file The code I provided seems to work for everything I want and Google seems to be understanding. At this point, my rankings have not been affected too much (a couple spots down), which is pretty good thus far. My initial question was whether my code was efficiently written. What I did was copy the code from your previous answer and pasted it into my htaccess file, making the changes to reflect my site name. I do want it to go to www versus without www. I've always wondered why when you post code in this forum it gets messed up? Wish there was a way around that so people can share code verbatim. Maybe you posted the answer and it had characters in it that I am not to have in the code, like the "( )"? Just a guess. Thanks for your help. Michael
|
g1smd

msg:4188358 | 7:30 pm on Aug 17, 2010 (gmt 0) |
Your original example code redirected to www.example.com but jd's example code redirected to example.com, without www, and that difference is crucial. Check which one you want to redirect to and make sure the code you use is exactly right. It will take forever to fix things, should you implement code that redirects in the 'wrong direction'.
|
jdMorgan

msg:4188988 | 4:11 am on Aug 19, 2010 (gmt 0) |
http://example.com and http://www.example.com are recognized as example domains and won't "get messed up" if you use them in posts. Otherwise, URLs will trigger the forum's auto-linking code, and you see the results... URLs inside contiguous [ code ] sections will not be autolinked. Where it is necessary outside of a [ code ] section to use other domains for clarity (such as http://newdomain.com and http://olddomain.com), you can 'break' the autolinking by including [bold] or [italic] bbCode pairs or by using the [ smilestopper ] code tags after the http: part of the URL. Jim
|
|