.htaccess 禁用子域的URL重写

.htaccess 禁用子域的URL重写,.htaccess,url-rewriting,subdomain,.htaccess,Url Rewriting,Subdomain,我正在使用ApacheWeb服务器(使用.htaccess处理URL重写) 主域(例如example.com)由WordPress生成的URL重写进行管理。URL重写适用于整个域,包括子域 我有一个名为http://static.example.com,它将URL转发到另一个外部URL,例如转发到http://www.google.com。那就是: 将期待 但是,URL重写会阻止它,并且报告找不到文件,因为它在本地服务器中找不到/css/style.css。我的问题是:如何禁用子域的URL重写

我正在使用ApacheWeb服务器(使用
.htaccess
处理URL重写)

主域(例如
example.com
)由WordPress生成的URL重写进行管理。URL重写适用于整个域,包括子域

我有一个名为
http://static.example.com
,它将URL转发到另一个外部URL,例如转发到
http://www.google.com
。那就是:

将期待

但是,URL重写会阻止它,并且报告找不到文件,因为它在本地服务器中找不到
/css/style.css
。我的问题是:如何禁用子域的URL重写

当前的
.htaccess
如下所示:

RewriteEngine on

AddType application/rss+xml rss
AddType application/x-java-jnlp-file jnlp
Options All -Indexes

RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^/?$ "http\:\/\/example\.com" [R=301,L]

# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
<FilesMatch "\.(css|htc|js|js2|js3|js4|CSS|HTC|JS|JS2|JS3|JS4)$">
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.11"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.11"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.11"
    </IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

RewriteCond %{HTTP_HOST} ^static\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.static\.example\.com$
RewriteRule ^/?$ "https\:\/\/google\.com\/css\/some_path\/" [R=301,L]
重新编写引擎打开
AddType应用程序/rss+XMLRSS
AddType应用程序/x-java-jnlp-file jnlp
选项所有-索引
重写cond%{HTTP_HOST}^www.example.com$
重写规则^/?$“http\:\/\/example\.com”[R=301,L]
#开始W3TC浏览器缓存
标头附加变量用户代理env=!不要改变
AddOutputFilterByType DEFLATE text/css text/x-component应用程序/x-javascript应用程序/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon应用程序/json
#扩展放气
AddOutputFilter DEFLATE js css htm html xml
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
#结束W3TC浏览器缓存
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
RewriteCond%{HTTP_HOST}^static\.example\.com$[或]
重写cond%{HTTP_HOST}^www\.static\.example\.com$
重写规则^/?$“https\:\/\/google\.com\/css\/some\u path\/”[R=301,L]
注意:注意,转发实际上包括在上面

p、 所有URL都是假的。

替换

RewriteCond %{HTTP_HOST} ^static\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.static\.example\.com$
RewriteRule ^/?$ "https\:\/\/google\.com\/css\/some_path\/" [R=301,L]

整个htaccess将:(调整)

重新编写引擎打开
AddType应用程序/rss+XMLRSS
AddType应用程序/x-java-jnlp-file jnlp
选项所有-索引
#开始W3TC浏览器缓存
标头附加变量用户代理env=!不要改变
AddOutputFilterByType DEFLATE text/css text/x-component应用程序/x-javascript应用程序/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon应用程序/json
#扩展放气
AddOutputFilter DEFLATE js css htm html xml
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
#结束W3TC浏览器缓存
#开始WordPress
重新启动发动机
重写基/
#将www.example.com/some重定向到example.com/some
重写cond%{HTTP_HOST}^www\.example\.com$
重写规则^(.*)$http://example.com/$1[R=301,L]
重写cond%{HTTP_HOST}^(www\)?static\.example\.com$
重写规则^(.*)$https://google.com/css/some_path/$1[R=301,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
更换

RewriteCond %{HTTP_HOST} ^static\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.static\.example\.com$
RewriteRule ^/?$ "https\:\/\/google\.com\/css\/some_path\/" [R=301,L]

整个htaccess将:(调整)

重新编写引擎打开
AddType应用程序/rss+XMLRSS
AddType应用程序/x-java-jnlp-file jnlp
选项所有-索引
#开始W3TC浏览器缓存
标头附加变量用户代理env=!不要改变
AddOutputFilterByType DEFLATE text/css text/x-component应用程序/x-javascript应用程序/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon应用程序/json
#扩展放气
AddOutputFilter DEFLATE js css htm html xml
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
标题集X-Powered-By“W3 Total Cache/0.9.2.11”
#结束W3TC浏览器缓存
#开始WordPress
重新启动发动机
重写基/
#将www.example.com/some重定向到example.com/some
重写cond%{HTTP_HOST}^www\.example\.com$
重写规则^(.*)$http://example.com/$1[R=301,L]
重写cond%{HTTP_HOST}^(www\)?static\.example\.com$
重写规则^(.*)$https://google.com/css/some_path/$1[R=301,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]

仍然找不到页面。Same.oups,我错误地添加了\现在应该可以工作了,我还调整了您的htaccessyes,它可以工作。有没有办法不更改URL,即保留
http://static.example.com/style.css
?仍然找不到页面。Same.oups,我错误地添加了\现在应该可以工作了,我还调整了您的htaccessyes,它可以工作。有没有办法不更改URL,即保留
http://static.example.com/style.css
RewriteEngine on

AddType application/rss+xml rss
AddType application/x-java-jnlp-file jnlp
Options All -Indexes


# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
<FilesMatch "\.(css|htc|js|js2|js3|js4|CSS|HTC|JS|JS2|JS3|JS4)$">
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.11"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$">
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.11"
    </IfModule>
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
    <IfModule mod_headers.c>
         Header set X-Powered-By "W3 Total Cache/0.9.2.11"
    </IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# redirect www.example.com/some to example.com/some
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?static\.example\.com$
RewriteRule ^(.*)$ https://google.com/css/some_path/$1 [R=301,L]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


</IfModule>