如何重定向
例如,如果我在搜索栏中输入subdomain.example.com,则按Enter键并将其重定向到subdomain.example.com/page
我如何在.htaccess
中执行此操作这就是我在.htaccess中所拥有的,但它不起作用:
#If Url is entered
RewriteCond %{HTTP_HOST} ^subdomain.example.com [NC]
#Redirect to
RewriteRule ^(.*)$ http://subdomain.example.com/page/$1 [L,R=301]
答案 0 :(得分:0)
您可以在子域的根.htaccess中使用此规则:
RewriteEngine On
#If Url is entered
RewriteCond %{HTTP_HOST} =subdomain.example.com
#Redirect to
RewriteRule ^((?!page/).*)$ /page/$1 [L,R=301,NC]