Probably a hornets nest here but was wondering whether it would be a good idea for a default in htaccess file to redirect www rather than let Google rank the same page with and without the domain prefix?
Something along the lines of:
#handle www
RewriteCond %{HTTP_HOST} ^domainname\.com$ [NC]
RewriteRule ^(.*)$ http://www. domainname.com/$1 [L,R=301]
----
Alan
header('Location: ' . htmlspecialchars( $redirectTo ), true, '301');
$app = & JFactory::getApplication();
$app->close();
Well, Louis, the htaccess file can always override what is done inside of Joomla!. So, for folks who have that skillset and need that type of performance tweek, adding "No WWW" redirects internally will not prevent them from using those methods. Most users who want that SEO benefit might not have those skills or be worried about that little bit of slowdown.
++++
Looking at the new Redirect Plugin, I see you are trapping the error, and providing this capability for 404's, only.
I handled it a bit differently. Any URL could be entered as an old value, and then redirected using a 301 header, to a new URL. (This would handle incorrect names where the initial URL is already used, and therefore, wouldn't 404) I used a System Plugin and the onAfterInitialise function as part of a Router override. It checks to see if the Plugin parameter is set, and if the subdomain is WWW, it performs a 301 redirect.
We could use that same approach, add an onAfterInitialise function to the Redirect System Plugin and a new Redirect Component Parameter and do the same thing.
But, since this would be a core change, it might make more sense to treat it like the Global Configuration option "Force SSL" and redirect right inside of the JRouterSite Class.
++++
Now, Louis, I have a question.
The 404 redirects and the SSL redirect do not force the 301.
I believe we need to force a 301 header -- or -- I don't think we will get the SEO benefit we are after. The 301 in the header is what signals the Googles of the world that this is an intentional and permanent change, and they should update their records for the 404, accordingly.
I believe we need to set header and then end the application in the Redirect plugin (and should make this change in the JRouterSite class, as well.)header('Location: ' . htmlspecialchars( $redirectTo ), true, '301');$app = & JFactory::getApplication();
$app->close();
Does that seem right to you?
if (headers_sent()) {
echo "<script>document.location.href='$url';</script>\n";
} else {
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
}
$this->close();
++++
Just some ideas, if you are against the No WWW internally for reasons previously mentioned, there is no sense creating a patch. There are also a few ways it could be done and I'm not certain which method you'd prefer.
If you want a patch, let me know what you want, and I can try to do that.
Thanks.
Hi Amy,On Mon, Nov 23, 2009 at 2:59 PM, Amy Stephen <amyst...@gmail.com> wrote:Well, Louis, the htaccess file can always override what is done inside of Joomla!. So, for folks who have that skillset and need that type of performance tweek, adding "No WWW" redirects internally will not prevent them from using those methods. Most users who want that SEO benefit might not have those skills or be worried about that little bit of slowdown.
So are we saying that most users who use joomla might not have the skills to edit an htaccess file? In the past we have had htaccess files that people edited -- over different types of URL mechanisms if memory serves.
++++
Looking at the new Redirect Plugin, I see you are trapping the error, and providing this capability for 404's, only.
I handled it a bit differently. Any URL could be entered as an old value, and then redirected using a 301 header, to a new URL. (This would handle incorrect names where the initial URL is already used, and therefore, wouldn't 404) I used a System Plugin and the onAfterInitialise function as part of a Router override. It checks to see if the Plugin parameter is set, and if the subdomain is WWW, it performs a 301 redirect.
We could use that same approach, add an onAfterInitialise function to the Redirect System Plugin and a new Redirect Component Parameter and do the same thing.
But, since this would be a core change, it might make more sense to treat it like the Global Configuration option "Force SSL" and redirect right inside of the JRouterSite Class.
Ya, thats certainly different. Thats much more like a custom sef url solution than what I built with redirect. Redirect was initially built when I needed to handle missing articles in the www.joomla.org migration from Joomla 1.0 to 1.5. What I needed it for was to redirect users from old pages that didn't exist anymore to new locations either on the existing site or at a new site. The beauty of the way its designed now is that for most page loads there is literally no extra work done -- unless a 404 is encountered. Changing to the way you describe would mean at least another database lookup and function call on every single page load.
++++
Now, Louis, I have a question.
The 404 redirects and the SSL redirect do not force the 301.
I believe we need to force a 301 header -- or -- I don't think we will get the SEO benefit we are after. The 301 in the header is what signals the Googles of the world that this is an intentional and permanent change, and they should update their records for the 404, accordingly.
I believe we need to set header and then end the application in the Redirect plugin (and should make this change in the JRouterSite class, as well.)header('Location: ' . htmlspecialchars( $redirectTo ), true, '301');$app = & JFactory::getApplication();
$app->close();
Does that seem right to you?I think you are missing something. The plugin calls JApplication::redirect(). You can see it on line 68 of /plugins/system/redirect.php as of revision 13566.$app->redirect($link->new_url);Which if you look on line 342 of /libraries/joomla/application/application.php you will find:if (headers_sent()) {
echo "<script>document.location.href='$url';</script>\n";
} else {
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
}
$this->close();
Which clearly sends a 301 if possible. If you are talking about something else, then I'm sorry but I am misunderstanding you.
++++
Just some ideas, if you are against the No WWW internally for reasons previously mentioned, there is no sense creating a patch. There are also a few ways it could be done and I'm not certain which method you'd prefer.
If you want a patch, let me know what you want, and I can try to do that.
Thanks.I'm certainly not the only voice here, if the release team wants it and you get it working and ready for the trunk then by all means, but its not something I personally would be working on. I personally think that if someone wants that, uncommenting a line in a htaccess file and/or setting something in Google Webmaster Tools is easy and simple enough.
> What about existing subdomains blog.domain.com or forum.domain.com? ;)
> User will get redirect to www.domain.com in any case.
Then you'll simply de-activate the rewrite rule.
Regards,
Niels
Actually this makes plenty of sense to me Amy. Shorter URL string –three more characters, less typing.
[The original htaccess code I posted allows sub domains fine on my server]
----
Alan
No
virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.421 / Virus Database: 270.14.72/2511 - Release Date: 11/18/09
07:50:00
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.425 / Virus Database: 270.14.80/2523 - Release Date: 11/24/09 07:46:00