Forum Moderators: phranque
I've been searching for a non-www to www set of rewrite rules, and found this fine post by jdMorgan:
Link: Non-WW to WWW [webmasterworld.com]# Externally redirect from non-www, non-canonical hostname to the
# canonical www hostname, preserving current HTTP/HTTPS protocol
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{SERVER_PORT}s ^(443(s)¦[0-9]+s)$
RewriteRule (.*) http%2://www.example.com/$1 [R=301,L]Replace the broken pipe "¦" character in the second RewriteCond pattern with a solid pipe before use; Posting on this forum modifies the pipe characters.
However, I was trying to adjust this (unsuccessfully) to also include any requests with subdirectories, such as:
http://example.com/clients REWRITE_TO-> http://www.example.com/clients
Can someone lend a hand on adding this modification? Thanks much
~Brite
No modification is required, as the requested URL-path (i.e. the "directory" and "file name" part) is captured by the RewriteRule pattern as "$1", and re-injected into the redirect target URL.
See the resources cited in our Forum Charter for more information.
Jim
Jim