Вопрос

How to redirect from domain.com/admins to www.domain.com/admins . I have tried editing .htaccess file but its not working . I have searched the internet but they have code for only domain.com to www.domain.com .

Это было полезно?

Решение

put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

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

That rule is only for /admins URI. If you want to do this for all the URIs then use:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top