g1smd

msg:4531176 | 7:09 pm on Dec 26, 2012 (gmt 0) |
It's difficult to tell you where you went wrong when you supplied no code. Make sure you have the very latest htaccess file; get it from a very recent Joomla package. Do this even if you are continuing to use an old version of Joomla. The redirects will need to go in the htaccess file in the root of the old site. They'll go before the non-www/www redirect and after any code that blocks access to malicious requests. Do not use Redirect or RedirectMatch. Use only RewriteRule with both the R=301 and L flags. The target URL must include the protocol and hostname. Make sure the RegEx pattern is start anchored and that all literal periods are escaped.
|
lucy24

msg:4531202 | 8:56 pm on Dec 26, 2012 (gmt 0) |
| these are urls that no longer exist in the root/new site |
| As long as one person or one robot requests it, the URL exists. Have you physically moved any material, or is it "only" your URL structure that has changed? You cannot use mod_alias (Redirect by that name) because it looks only at the requested path. You need mod_rewrite with a RewriteCond that looks at the requested domain name (either example.com or subdomain.example.com). Are you still using (www.)example.com for anything, or do you want to point everything to the subdomain? If you had no redirects/rewrites in place, where would requests for the subdomain end up? If it lives in a directory that is physically* inside the main-domain directory-- this is the most common setup-- then all requests for the subdirectory will pass through the main domain's htaccess. * Yes, OK, for a given definition of "physically". Your server is not made out of manila file folders. But we don't usually need to go there.
|
innocbystr

msg:4531221 | 10:22 pm on Dec 26, 2012 (gmt 0) |
Thanks all. I feel kind of silly now. While looking for a RewriteRule example I ran across a post that mentioned that cPanel has a redirect writing gizmo. Didn't host with anyone that had cPanel until recently and then never paid much attention to it. Anyway this is what it came up with: RewriteCond %{HTTP_HOST} ^example\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule ^blog\/?(.*)$ "http\:\/\/archive\.example\.com\/blog\/$1" [R=301,L] Glad it works. I don't put on my 'developer hat' very often and have no idea what most of it means or what it does. I'll have to look for some sort of 'Dummies guide to .htaccess'. Don't really like using wysiwyg widgets but in this case useful.
|
g1smd

msg:4531226 | 10:46 pm on Dec 26, 2012 (gmt 0) |
You missed the further post that said that cPanel writes the absolute worst mod_rewrite code on the planet. There are very many syntax and logic errors in that code. The hostname tests don't capture all non-canonical versions such as example.com:80 etc. In any case the code doesn't need to test the requested hostname if the code is in the right htaccess file. Slashes in patterns don't need escaping. The rule target shouldn't be in quotes. The escaping on the colons, slashes and periods in the rule target are all errors.
RewriteRule ^blog/(.*) http://archive.example.com/blog/$1 [R=301,L] or
RewriteRule ^(blog/.*) http://archive.example.com/$1 [R=301,L]
|
innocbystr

msg:4531251 | 12:29 am on Dec 27, 2012 (gmt 0) |
Thanks g1smd. Replaced cPanel hieroglyphics with yours and working fine. Wondered what in the world all those chicken scratches did. Glad I found out before I re-directed any more sub-directories.
|
g1smd

msg:4531431 | 12:54 pm on Dec 27, 2012 (gmt 0) |
Whoever wrote the code for cPanel used the type of escaping that is used for JavaScript code, and didn't bother to look up exctly what escaping is needed for htaccess. You can instantly tell when a chunk of code was produced by cPanel. The same errors are in use on tens of millions of websites.
|
|