0

How can I redirect www to non www for sub-directories? It is OK for home page but for sub-directories, it doesn't work. My sub-directory files have dynamic content.

My .htaccess is:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} !^www
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R]
RewriteRule blog/(.*)/ viewpost.php?page=$1
RewriteRule blog/(.*) catpost.php?page=$1

but it only affects the home page, not sub-directories.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
vo8091
  • 9
  • 2
  • Does this answer your question? [Generic htaccess redirect www to non-www](https://stackoverflow.com/questions/234723/generic-htaccess-redirect-www-to-non-www) – kmoser Aug 21 '21 at 06:47
  • Now what, subdirectories or subdomain? – arkascha Aug 21 '21 at 09:26

0 Answers0