我想从我的网站网址中删除www。
即。 https://www.domainname.com.au至https://domainname.com.au。
我已尝试过各种.htacces代码,但对我来说没什么用。
以下是我目前的代码,它从http中删除www但不适用于https。
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://domainname.com.au/$1 [R=301,L]
RewriteRule ^code-of-conducts/(.*)/$ code-of-conducts.php?type=$1
RewriteRule ^parents/post-a-job/(.*)/EDIT/$ parents/post-a-job.php?action=EDIT&id=$1
RewriteRule ^parents/post-a-job/(.*)/$ parents/post-a-job.php?job_type=$1
RewriteRule ^parents/open-jobs/(.*)/delete/$ parents/open-jobs.php?action=delete&id=$1
RewriteRule ^parent-profile/(.*)/$ parent-profile.php?id=$1
RewriteRule ^parents/job-details/(.*)$ parents/job-details.php?applied_id=$1
RewriteRule ^sitterprofile/(.*)/$ sitterprofile.php?id=$1
RewriteRule ^sitter/job-board/state/(.*)/page/(.*)/$ sitter/job-board.php?state=$1&in_page=$2
RewriteRule ^sitter/job-board/state/(.*)/$ sitter/job-board.php?state=$1
RewriteRule ^sitter/job-details/(.*)$ sitter/job-details.php?applied_id=$1
RewriteRule ^(.*)/$ $1.php
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%2://%1%{REQUEST_URI} [L,R=301]
在这方面的任何帮助将受到高度赞赏。
答案 0 :(得分:0)
RewriteCond %{HTTPS_HOST} ^www\.(.*)$ [NC]
RewriteRule ^/(.*)$ https://%1/$1 [R=301,L]
尝试添加此内容。
答案 1 :(得分:0)
将第一个www
删除代码替换为:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]