Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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如何打开子文件夹中的文件?_Apache_.htaccess - Fatal编程技术网

Apache .htaccess如何打开子文件夹中的文件?

Apache .htaccess如何打开子文件夹中的文件?,apache,.htaccess,Apache,.htaccess,我在子目录中有许多动态子域的站点地图文件: /用于town1.mysite.com的sitemap/town1.xml /用于town2.mysite.com的sitemap/town2.xml 我应该如何配置.htaccess,该请求将打开文件?毕竟,我找到了这个解决方案: RewriteCond %{REQUEST_URI} ^/sitemap.xml$ RewriteCond %{HTTP_HOST} ^(.*)\.site\.com RewriteRule ^(.*)$ http:/

我在子目录中有许多动态子域的站点地图文件:

  • /用于town1.mysite.com的sitemap/town1.xml
  • /用于town2.mysite.com的sitemap/town2.xml

我应该如何配置.htaccess,该请求将打开文件?

毕竟,我找到了这个解决方案:

RewriteCond %{REQUEST_URI} ^/sitemap.xml$
RewriteCond %{HTTP_HOST} ^(.*)\.site\.com
RewriteRule ^(.*)$ http://%1.site.com/sitemap/%1.xml [L,NC,P]