htaccess Rewrite Questions
Thank you in advance. Here is my question:
I placed the following 2 lines of code in my .htaccess file to redirect non-WWW to WWW:
Last year, cPanel was upgraded on my server and it now "adds its own code" to my .htaccess file. Here is what is looks like now:
Question 1.) It looks like cPanel only put rewrite 'Conditions'... where is its rewrite 'Rule' ?? Question 2.) Their code interspersed with my code... wouldn't it be better if I pulled out my code and placed it at the beginning, so the end result looks like this?
Question 3.) If I change around the code, do I have to do this every month when cPanel 'refreshes' and/or adds new code? Question 4.) I'm a 'newbie' when it comes to Rewrites... what your your thoughts regarding my questions -- any further suggestions, or questions I failed to ask? Thank you again!
RewriteCond %{http_host} ^example.com [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Last year, cPanel was upgraded on my server and it now "adds its own code" to my .htaccess file. Here is what is looks like now:
RewriteEngine On
RewriteCond %{http_host} ^example.com [nc]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
Question 1.) It looks like cPanel only put rewrite 'Conditions'... where is its rewrite 'Rule' ?? Question 2.) Their code interspersed with my code... wouldn't it be better if I pulled out my code and placed it at the beginning, so the end result looks like this?
RewriteEngine On
RewriteCond %{http_host} ^example.com [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
Question 3.) If I change around the code, do I have to do this every month when cPanel 'refreshes' and/or adds new code? Question 4.) I'm a 'newbie' when it comes to Rewrites... what your your thoughts regarding my questions -- any further suggestions, or questions I failed to ask? Thank you again!
Please sign in to leave a comment.
Comments
0 comments