如果传递了某个.htacess
参数,是否有办法在GET
中制作不同的重写规则?
例如,如果查询字符串是:
htttp://domain.com/?debug=1
,而不是.htaccess
应该是这样的:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
如果查询字符串中没有debug=1
,则为:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule !\.(js|ico|gif|jpg|png|css|html|swf|flv|xml)$ index.php?$1 [QSA,L]
答案 0 :(得分:3)
您可以像这样使用RewriteCond
:
RewriteEngine on
# ?debug=1 is present
RewriteCond %{QUERY_STRING} (^|&)debug=1\b [NC]
RewriteRule (.*) app/webroot/$1 [L]
# ?debug=1 is not present
RewriteCond %{QUERY_STRING} !(^|&)debug=1\b [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule !\.(js|ico|gif|jpg|png|css|html|swf|flv|xml)$ index.php?$1 [QSA,L]
答案 1 :(得分:2)
您希望与RewriteCond中的查询字符串匹配:
background: url(../IMAGES/background.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
/* For mobile devices */
@media only screen and (max-width: 767px) {
/* The file size of this background image is 93% smaller
* to improve page load speed on mobile internet connections */
background: url(images/background-photo-mobile-devices.jpg);
}
}
有关详细信息,请参阅docs或this example。