douglas81 Posted September 18, 2014 Share Posted September 18, 2014 There's an option in the current .htaccess to forward to the www version of your site. But... I prefer a URLs without a www. However, I would still like said URLs to be accessible should someone type in the www sub-domain in their URL bar, or link to the "www version" of the URL. If you're like me, this could be a useful addition to the .htaccess file... # ----------------------------------------------------------------------------------------------- # OPTIONAL: Redirect users to the non 'www.' version of the site (uncomment to enable). # For example: http://www.processwire.com/ would be redirected to http://processwire.com/ # ----------------------------------------------------------------------------------------------- #RewriteCond %{HTTP_HOST} ^www\. #RewriteCond %{HTTPS}s ^on(s)|off #RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$ #RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L] For me, this is the simplest way to do things. It also means any auto-populated canonical tags, such as... <link rel="canonical" href="<?php echo $page->httpUrl; ?>"> ...will never display the www version of your site. I know many of you will know this already, but I always forget exactly what to put in there, so this will come in useful for me and others in future, I hope! What are your thoughts on this? Some other solutions? I've heard about mod_alias also? How would that work in conjunction with ProcessWire? Would it be a better solution? 2 Link to comment Share on other sites More sharing options...
Nico Knoll Posted September 18, 2014 Share Posted September 18, 2014 I think it's better to put this post in the Wishlist? Link to comment Share on other sites More sharing options...
douglas81 Posted September 18, 2014 Author Share Posted September 18, 2014 Ah yeah, maybe. Although, it's quite a personal thing, so maybe not appropriate for the majority of users. (EDIT: but you or any mod... please feel free to move it if you like) Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 18, 2014 Share Posted September 18, 2014 For canonical, why not type the hostname static and append the $page->url ? Or am I missing something ? Link to comment Share on other sites More sharing options...
douglas81 Posted September 18, 2014 Author Share Posted September 18, 2014 For canonical, why not type the hostname static and append the $page->url ? Or am I missing something ? I just wonder if that rubs against the grain of ProcessWire a bit...? I like the idea in ProcessWire that everything is relative and that you can just drag an installation to another folder (or, indeed, domain name), if you so desire. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 18, 2014 Share Posted September 18, 2014 The page's URL's start at server's document root, so it should not be an issue. And the chances are small that you will decide to switch to an other canonical. 1 Link to comment Share on other sites More sharing options...
douglas81 Posted September 18, 2014 Author Share Posted September 18, 2014 The page's URL's start at server's document root, so it should not be an issue. And the chances are small that you will decide to switch to an other canonical. Good point. Link to comment Share on other sites More sharing options...
douglas81 Posted September 18, 2014 Author Share Posted September 18, 2014 Although, if you like to copy and paste re-usable template fragments from site to site, being able to use page->httpUrl has it's merits. Actually, slightly OT, but that brings up another canonical question... how does one deal with https:// vs http:// in canonical? I mean, does that matter for SEO? Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 18, 2014 Share Posted September 18, 2014 You could force the scheme in your template settings. For SEO, I really don't know. But I think if you don't communicate that you serve HTTPS next to HTTP, I don't think search engines will try to crawl the whole site again over HTTPS. And if it does I can't imagine you'll get bad points for it. Correct me when i'm wrong. offtopic, $page->httpUrl very handy for newsletters Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 18, 2014 Share Posted September 18, 2014 http:// and https:// does matter, so you should use the canonical link. Also google does reward you for switching to https:// as default. source: 3 Link to comment Share on other sites More sharing options...
douglas81 Posted September 18, 2014 Author Share Posted September 18, 2014 @LostKobrakai: I'll check that video out, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now