需要在内部重写 test.example.com/images/* 到 example.com/images/*
test.example.com 的位置是文件结构中的 /sub_ds/test/。
希望这是有道理的。目前,链接到子域中的 /images/test.jpg 会在 test.example.com/images/test.jpg 查找文件,该文件显然不存在,这就是我寻找重写的原因。
添加 :
当前进程:
选项 +SymLinksIfOwnerMatch
# BEGIN rewrites
RewriteEngine On
# Externally redirect client requests for example.com/sub_ds/<subdomain>/<URLpath> to <subdomain>.example.com/<URLpath>
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /sub_ds/
RewriteRule ^sub_ds/([^/]+)/(.*)$ http://$1.example.com/$2 [R=301,L]
# Externally redirect client requests for www.[subdomain].example.com/sub_ds/<subdomain>/<URLpath> to <subdomain>.example.com/<URLpath>
RewriteCond %{HTTP_HOST} ^www\.([a-z0-9-]+)\.example\.com
RewriteRule ^sub_ds/([^/]+)/(.*)$ http://$1.example.com/$2 [R=301,L]
# Externally redirect 'secure' subdomain to https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^secure\.
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Externally redirect non 'secure' subdomain to http
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^secure\.
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Externally redirect index.(php|html?) in any location, preserving parameters, to location root
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ /phpsite/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]*/)*)index\.(php|html?)(\?[^\ ]*)?\ HTTP
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]
# BEGIN non-www to www
RewriteCond %{HTTP_HOST} !^(([a-z0-9][-a-z0-9]+)\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# Internally rewrite <subdomain>.example.com/<URLpath> to example.com/sub_ds/<subdomain/<URLpath>
RewriteCond $1 !^sub_ds/
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /sub_ds/%1/$1 [L]
目标...使 test.example.com/images/* 指向 example.com/images/*
子域物理上位于根目录中的子文件夹(通常具有大多数设置)。所以测试子域物理上位于 /sub_ds/test/