Jump to content

Possible Bug in default Processwire .htaccess file


joer80
 Share

Recommended Posts

I think I might have found a bug in thedefault processwire .htaccess file.


 

  # -----------------------------------------------------------------------------------------------
  # OPTIONAL: Redirect users to the 'www.' version of the site (uncomment to enable).
  # For example: http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]



It is common to need to preform a redirect like this to send non www users to a www address, so we include this code snippet in the default file that just needs to be enabled.  
 
It works great for domainname.com -> www.domainname.com, but the issue is it does not work for subdomains.  
 
We need to add code that does not forward a subdomain like   test.domain.com to www.test.domain.com.  
 
Let me know if this is an easy fix!  I could use it for the multi website project I am working on since the module only works on the www version.
 
Thanks!
Link to comment
Share on other sites

That's not that simple as the regex does not have any knowledge about any domain level specifics. I'm not sure if there's any way to hit "myenglishdomain.co.uk", but not "subdomain.domain.com" other than having different regex formulas for both. 

# First Level Domain (e.g. *.com)
!^(www)\.([^\.]+)\.([^\.]+)$
# Second Level Domain (e.g. *.co.uk)
!^(www)\.([^\.]+)\.([^\.]+)\.([^\.]+)$
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...