如果不匹配url则重写条件

时间:2017-01-25 17:43:42

标签: apache .htaccess redirect mod-rewrite zend-framework2

在我的Zend Framework 2项目中,我正在将https重定向到http,但我希望这种重定向对某些URL不起作用,我试过这种方式:

RewriteEngine on

# redirect no-www to www only main domain, not with subdomain
RewriteCond %{HTTP_HOST} ^(domain\.net)$ [NC]
RewriteRule ^ http://www.%1%{REQUEST_URI} [R=301,L]

# redirect https to http all domain
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/admin.*
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

# active la génération des en-têtes Expires
ExpiresActive On
ExpiresDefault "access plus 1 month"

如果我转到https admin url,我会被重定向到mydomaine.net/index.php,但我不知道为什么?

0 个答案:

没有答案