Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 使用HTACCESS重写index.html并重定向http://site.com 到http://www.site.com_Apache_.htaccess_Redirect - Fatal编程技术网

Apache 使用HTACCESS重写index.html并重定向http://site.com 到http://www.site.com

Apache 使用HTACCESS重写index.html并重定向http://site.com 到http://www.site.com,apache,.htaccess,redirect,Apache,.htaccess,Redirect,在.htaccess中,我看到了如何重写/index.html以指向主域: RewriteEngine on RewriteCond %{THE_REQUEST} ^.*\/index\.html?\ HTTP/ RewriteRule ^(.*)index\.html?$ "/$1" [R=301,L] 我还了解.htaccess如何防止网站在WWW下或没有WWW的情况下被索引 RewriteEngine on rewritecond %{http_host} ^mycustomcloset

在.htaccess中,我看到了如何重写/index.html以指向主域:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*\/index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ "/$1" [R=301,L]
我还了解.htaccess如何防止网站在WWW下或没有WWW的情况下被索引

RewriteEngine on
rewritecond %{http_host} ^mycustomcloset.com [nc]
rewriterule ^(.*)$ http://www.mycustomcloset.com/$1 [r=301,nc]
但是你如何同时做到这两个呢


换句话说,我希望mycustomclocker.com和mycustomclocker.com/index.html都指向

关于您的问题,我不理解第一个代码,但是您仍然可以尝试以下代码:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R,NE]
现在,如果您还想将mycustomclock.com/index.html和www.mycustomclock.com/index.html重定向到www.mycustomclock.com,那么您可以尝试以下方法:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R,NE]

RewriteRule ^index.html$ http://www.mycustomcloset.com [R,NE]

我不理解您问题的第一个代码,但是您仍然可以尝试以下代码:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R,NE]
现在,如果您还想将mycustomclock.com/index.html和www.mycustomclock.com/index.html重定向到www.mycustomclock.com,那么您可以尝试以下方法:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R,NE]

RewriteRule ^index.html$ http://www.mycustomcloset.com [R,NE]

也许这能帮上忙也许这能帮上忙谢谢!你知道如何使你的代码也重定向到吗?@JayFrostWebDesign请检查我的更新!只是别忘了接受一个确切的答案,通知观众。谢谢!你知道如何使你的代码也重定向到吗?@JayFrostWebDesign请检查我的更新!只是别忘了接受一个确切的答案来通知观众。