使用Apache mod_rewrite将主机重写到子文件夹,但redirect而不是重写
我想通过.htaccess模拟虚拟主机,所以我想重写主机名到子文件夹。 它工作,但在一些URL不重写,但redirect。 这是我的.htacess文件: RewriteEngine on RewriteBase / # Rewrite from subdomains to subfolders with builds RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.ci\.example\.com$ RewriteCond %{REQUEST_URI} !^/builds/ RewriteCond %{REQUEST_URI} !^/robots.txt RewriteRule ^(.*)$ /builds/%2/%1/$1 [PT] # Example project RewriteCond %{HTTP_HOST} ^old\.domain\.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] # Rewrite production to master subfolder RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteCond %{REQUEST_URI} !^/builds/ […]