我在一个文件中得到了一些 mod_rewrite 条件.htaccess
,我时不时地会对其进行扩展。但我认为它写得不是很好(我对 mod_rewrite 还很陌生)
有时请求会陷入无限循环
刚才我已将 SSL 添加到文件中。
当请求时https://
我收到 404 错误,The requested URL /_secure/_secure/ was not found on this server.
它会以某种方式在路径中添加额外的 _secure?
.htaccess
# redirect non-active subdomain to 'www'
RewriteCond %{HTTP_HOST} !^(admin|api|demo|files|secure|www)\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://www.domain.com [L,R=301]
# put 'www' as subdomain if none is given
RewriteCond %{HTTP_HOST} ^([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [L,R=301]
# redirect to subdomain
RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule ^_([^/]+)/ http://$1.%1/ [L,R=301]
# start SSL on 'secure' subdomain if not started
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} ^(secure)\.([^\.]+\.[^\.]+)$ [NC]
#RewriteRule ^(.*)$ https://%1.%2/$1 [L,R=301]
# set language
RewriteCond %{REQUEST_URI} ^/(da|en)/(.*)(\?%{QUERY_STRING})?$ [NC]
RewriteRule ^(.*)$ /%2?%{QUERY_STRING}&set_lang=%1 [L]
# subdomains
# --------------------------------------------------------------------------------
# rewrite subdomain
RewriteCond %{HTTP_HOST} ^(admin|files)\.[^\.]+\.[^\.]+$ [NC]
RewriteCond %{REQUEST_URI} !^/_(admin|files)/ [NC]
RewriteRule ^(.*)$ /_%1/$1 [L]
# rewrite 'secure' subdomain
RewriteCond %{HTTP_HOST} ^(demo|secure)\.[^\.]+\.[^\.]+$ [NC]
RewriteCond %{REQUEST_URI} !^/_secure/ [NC]
RewriteRule ^(.*)$ /_secure/$1 [L]
# rewrite 'api' subdomain
RewriteCond %{HTTP_HOST} ^api\.[^\.]+\.[^\.]+$ [NC]
RewriteCond %{REQUEST_URI} !^/_api/ [NC]
RewriteRule ^(?:([^/]+)/)?(?:([^/]+)/)?(?:([^/]+)/)?(?:([^/]+)/)?(?:([^/]+)/)?(?:([^/]+)/)? /_api/?%{QUERY_STRING}&v=$1&i=$2&k=$3&a=$4&t=$5&f=$6 [L]
# translate SEO-friendly URL's
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.php$ [NC]
RewriteCond %{REQUEST_URI} ^/([^/]*)/(?:([^/]*)/)?(?:([^/]*)/)?$ [NC]
RewriteRule ^(.*)$ /%1.php?%{QUERY_STRING}&subpage=%2&subsection=%3 [L]
答案1
发现了问题所在。
/_secure
我还在DocumentRoot 中附加了httpd.conf