rkingon / Craft-Plugin--Redirect-Manager

MIT License
46 stars 16 forks source link

Possible to handle 'www' to 'non-www' redirects? #24

Closed dace closed 8 years ago

dace commented 8 years ago

Wondering if this plug-in works with handling www to non-www 301 redirects (if so, how)? It appears that the matching uri examples only work with sub-level redirects.

Thanks!

rkingon commented 8 years ago

It supports it, line 55 in the service shows:

`return (isset($redirectLocation)) ? array("url" => ( strpos($record['location'], "http") === 0 ) ? $redirectLocation : UrlHelper::getSiteUrl($redirectLocation), "type" => $record['type']) : false;``

if the redirect string starts with http it uses the url, else builds a siteUrl

dace commented 8 years ago

Hi, thanks for the quick response. Just so I understand - does the 301 redirect from 'www' to 'non-www' have to be configured outside of the plugin (either through an htaccess or NGINX config) or does the matching uri field in the plugin allow you to manage this 'www' to 'non-www' redirect (if so, how)? Thanks!!

rkingon commented 8 years ago

I totally mis-read your message.. I thought you were looking for internal vs external when you said www -- now I think you're saying like "yoursite.com" -> "www.yoursite.com" ?

If so, that is NOT handled by this plugin or any other. This is something you need to do at a server level (.htaccess w/ apache or w/ sites-available/your-site in nginx).

which are you running?

dace commented 8 years ago

Ah, gotcha. Yeah, I'm actually going from 'www.mysite.com' and I want to redirect it to the non-www version --> 'mysite.com'. I'm running NGINX, so will configure it through the server. Appreciate it. For all other sub-level redirects, this plug-in has been really great, easy to work with. Thanks!