Note that there are some explanatory texts on larger screens.

plurals
  1. POremove www from https
    primarykey
    data
    text
    <p>I'm trying to find a htaccess rewrite to remove www. from https: pages only. Every article I've found removes www for all pages.</p> <p>What do I need in .htaccess to do this?</p> <p><a href="https://www.mydomain.com" rel="nofollow">https://www.mydomain.com</a> should be <a href="https://mydomain.com" rel="nofollow">https://mydomain.com</a></p> <p><a href="https://mydomain.com" rel="nofollow">https://mydomain.com</a> should remain <a href="https://mydomain.com" rel="nofollow">https://mydomain.com</a></p> <p><a href="http://www.mydomain.com" rel="nofollow">http://www.mydomain.com</a> should remain <a href="http://www.mydomain.com" rel="nofollow">http://www.mydomain.com</a></p> <p><a href="http://mydomain.com" rel="nofollow">http://mydomain.com</a> should remain <a href="http://mydomain.com" rel="nofollow">http://mydomain.com</a></p> <p>I've been able to get the following working:</p> <pre><code>RewriteCond %{HTTPS}s ^on(s)| RewriteCond http%1://%{HTTP_HOST}%{REQUEST_URI} ^(https?://)www\.(.+) [NC] RewriteRule ^ %1%2 [L,R,QSA] </code></pre> <p>But this rewrites both https and http</p> <p>Here is my current .htaccess</p> <pre><code>SetEnv DEFAULT_PHP_VERSION 5 RewriteEngine on RewriteOptions MaxRedirects=1 # You may need to uncomment the following line on some hosting environments, # for example on unitedhosting.co.uk # RewriteBase / # The following line has been added in order to exclude the webim # directory from the LemonStand URL processing. RewriteCond %{REQUEST_URI} !^/webim # # Do not allow executing any PHP scripts # RewriteRule ^(.*).php$ index.php [L] # # The following section automatically adds a trailing slash to all URLs # RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteCond %{HTTP:X-REQUESTED-WITH} !^(XMLHttpRequest)$ RewriteCond %{REQUEST_METHOD} !^HEAD$ RewriteCond %{REQUEST_METHOD} !^POST$ RewriteRule (.*)([^/])$ %{REQUEST_URI}/ [R=301,L] # The following line has been added in order to exclude the webim # directory from the LemonStand URL processing. RewriteCond %{REQUEST_URI} !^/webim # # Product files downloading URL # RewriteRule (^download_product_file/.*) index.php?q=/$1 [L,QSA] # The following line has been added in order to exclude the webim # directory from the LemonStand URL processing. RewriteCond %{REQUEST_URI} !^/webim # # Administration Area file downloading URL # RewriteRule ls_backend/files/get/(.*) index.php?q=/backend_file_get/$1 [L] # The following line has been added in order to exclude the webim # directory from the LemonStand URL processing. RewriteCond %{REQUEST_URI} !^/webim # # All other requests # RewriteCond %{REQUEST_URI} !(\.(ico|js|jpg|gif|css|png|swf|flv|txt|xml|xls|pdf|eot|woff|ttf|svg|mp4)$) RewriteCond %{REQUEST_URI} !(phproad/thirdpart/.*) RewriteRule ^(.*)$ index.php?q=/$1 [L,QSA] ErrorDocument 404 "File not found" # # PHP configuration # &lt;IfModule mod_php5.c&gt; php_flag session.auto_start off php_value session.cookie_lifetime 31536000 php_flag session.use_cookies on php_flag session.use_only_cookies on php_value session.name FWCSESSID php_flag short_open_tag on php_flag asp_tags on php_flag magic_quotes_gpc off php_value date.timezone GMT php_value post_max_size 100M php_value upload_max_filesize 100M php_value memory_limit 264M &lt;/IfModule&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload