我正在尝试关注Paul Irish的示例,了解如何在/publish建立我的网站的缩小版本。 我已成功集成自动构建过程但无法将.htaccess文件指向正确的文件夹。
我的目标:
在实时服务器上将所有正常站点流量重定向到/publish文件夹以使用“构建”站点。 但是当在开发服务器上使用/ normal根文件夹中的开发文件时。
我的问题:
我希望htaccess将请求从root重写到/publish目录。 由于在/和/publish目录中将使用相同的htaccess,我需要一个重写条件来阻止它将/publish目录中的请求重写到/publish/publish/my-page 。 我现在有这个:
RewriteCond %{SCRIPT_FILENAME} !^/publish/.+ RewriteRule ^(.*)$ publish/$1 [L]上面的条件查找没有以/publish开头的script_filename请求。 如果是这样,它应该使用publish/ in重写请求。
但是,这不起作用。 有没有人有什么想法呢? 我可以使用不同的服务器变量来识别请求是否在/publish目录中。
I am trying to follow Paul Irish's example of how to have a built minified version of my site inside /publish. I have successfully integrated the automated build process but can't get the .htaccess file to point to the correct folder.
My Aim:
When on live server to redirect all normal site traffic to the /publish folder to use the 'built' site. But when on the development server to use the development files in the / normal root folder.
My Problem:
I want the htaccess to rewrite requests from the root to the /publish directory. As the same htaccess be will used inside the / and /publish directory I need a rewrite condition to stop it rewriting requests inside the /publish directory to /publish/publish/my-page. I have this at present:
RewriteCond %{SCRIPT_FILENAME} !^/publish/.+ RewriteRule ^(.*)$ publish/$1 [L]The condition above looks for requests that do not have the script_filename starting with /publish. If so it should rewrite the request with publish/ in front.
However, this is not working. Does anyone have any ideas what is wrong with it? Could I use different server variables to identify if the request is in the /publish directory or not.
最满意答案
您应该使用%{REQUEST_URI}因为它是具有相对于站点根目录的路径的正确变量,而不是其他物理文件名。
RewriteCond %{REQUEST_URI} !^/publish/ RewriteRule ^(.*)$ publish/$1 [L]You should use %{REQUEST_URI} instead as it is the correct variable that will have path relative to the site root and not physical file name like others.
RewriteCond %{REQUEST_URI} !^/publish/ RewriteRule ^(.*)$ publish/$1 [L]更多推荐
发布评论