在我的根.htaccess我有
Options +FollowSymlinks
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/dashboard/
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^dashboard.domain.com
RewriteRule ^(.*)$ /dashboard/$1 [NC,L,NS]
在仪表板文件夹中.htaccess我有..
RewriteRule ^go/([^/.]+)/?$ index.php?flag=$1 [L]
当我访问dashboard.domain.com/login时,它会引发错误。 当我去dashboard.domain.com/go/a时,它可以工作。
当我#out the dashboard rewrite rule相反时,/ login工作,但是/ go / $ 1则没有。只有在检测到/ go时才会使用什么才能进行/ go重写?
编辑(其他根htaccess)
AddHandler application/x-httpd-php54 .php
Options +FollowSymlinks
Options -Indexes
RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} !^/rocket/
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^launch.domain.com
RewriteRule ^(.*)$ /rocket/$1 [NC,L,NS]
RewriteCond %{REQUEST_URI} !^/dashboard/
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^dashboard.domain.com
RewriteRule ^(.*)$ /dashboard/$1 [NC,L,NS]
RewriteCond %{REQUEST_URI} !^/img/
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^img.domain.com
RewriteRule ^(.*)$ /img/$1 [NC,L,NS]
#RewriteCond %{HTTPS} off
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [NC]
#RewriteCond %{HTTP_HOST} !launch.domain.com [NC]
#RewriteRule ^(.*)$ https://launch.domain.com/$1 [R=301,L,QSA]
Redirect 301 /sneakpeek /
RewriteRule ^error/([^/]+) error/failure.php?code=$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
<FilesMatch "\.(ttf|otf|eot|woff|jpg|png|jpeg|gif|js|json|html|css|php)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
ErrorDocument 400 /error/400
ErrorDocument 401 /error/401
ErrorDocument 403 /error/403
ErrorDocument 404 /error/404
ErrorDocument 500 /error/500
答案 0 :(得分:2)
信息中心规则下方的规则可能会影响您的规则并更改%{REQUEST_URI}
变量。您可以使用THE_REQUEST
变量并在清除浏览器缓存后重新测试它:
RewriteCond %{THE_REQUEST} !/(dashboard|error)/
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} =dashboard.domain.com
RewriteRule ^(.*)$ dashboard/$1 [NC,L]