Jump to content

urlSegments and www redirect in .htaccess problem


Hani
 Share

Recommended Posts

I've enabled the redirect in .htaccess that will add www. to the URL if someone visits the site without it.  However, it seems like the redirect does not take into consideration urlSegments and simply ignores them.  

For example, if someone goes to

http://mydomain.com/section/urlSegment1/
 

They are redirected to

http://www.mydomain.com/section/
 

The section in the .htacess that was enabled are these two lines

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Anyone have any thoughts or a solution?  I'm an amateur when it comes to .htaccess.

Link to comment
Share on other sites

Thanks, Alessio.  However, that didn't seem to fix the issue I'm experiencing.  It still seems to behave in the same manner.

I suppose I should also ask, is anyone else able to confirm that this happens for them too?  Or is this unique to my setup?  My "section" page is set to allow URL segments of course.

Link to comment
Share on other sites

I'm not really sure what could be causing that. Apache and .htaccess know nothing about URL segments... that is only a ProcessWire term. To Apache/.htaccess those URL segments are just a part of the REQUEST_URI like anything else. I would comment out that directive in your .htaccess and look elsewhere (in your .htaccess and in your PW templates) to see where the redirect might be coming from. 

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...