Apache .htaccess忽略某些目录,但传递子域 现有的.htaccess文件

Apache .htaccess忽略某些目录,但传递子域 现有的.htaccess文件,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,======= currently its doing this: https://hello.domain.com --> https://hello.domain.com/index.php?sub=hello https://hello.domain.com/dir1/15 --> https://hello.domain.com/index.php?path=dir1/15&sub=hello https://hello.domain.com/index.php -

=======

currently its doing this:

https://hello.domain.com --> https://hello.domain.com/index.php?sub=hello
https://hello.domain.com/dir1/15 --> https://hello.domain.com/index.php?path=dir1/15&sub=hello
https://hello.domain.com/index.php --> https://hello.domain.com/index.php
https://hello.domain.com/images/logo.png --> https://hello.domain.com/images/logo.png

what needs to happen:

1. https://hello.domain.com/index.php --> https://hello.domain.com/index.php?sub=hello
(当前sub=未追加hello)

(“/process”目录需要忽略,但“sub=hello”仍然需要传递)

基本上,我需要对规则进行一些补充,以确保#1和#2也能正常工作。不应更改现有规则

提前谢谢

您的完整.htaccess:

RewriteEngine on
RewriteBase /

# if not https, redirect
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ignore any .cfm|.html|.asp|.ico files and certain directories
RewriteRule ^(php|images|css|js|xyz|(.*)\.html|(.*)\.asp|(.*)\.ico)($|/) - [L]

# parse the subdomain as a variable we can access
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^app
RewriteCond %{HTTP_HOST} ^([^.]+)\.[^.]+\.[^.]+$
RewriteRule ^(.*)$ index.php?sub=%1&path=$1 [L,QSA]

%{ENV:REDIRECT_STATUS}
是一个内部变量,在第一次内部重写后设置为200。

它几乎做到了这一点。但现在我明白了:它确实解决了这个问题,但现在其他东西不起作用了。hello.domain.com/about/a.php应该是hello.domain.com/index.php?sub=hello&path=about/a.php,但它缺少了“path=about/a.php”ok,好得多,但仍然不是很好。有两个条件没有满足。1.任何未在忽略规则中列出的文件夹都需要转到“index.php”,例如:需要为2。因为它不需要重复两次。现在我得到这个:它打破了这个:应该是:。相反,我得到的是:
2. https://hello.domain.com/process/generate.php --> https://hello.domain.com/process/generate.php?sub=hello
RewriteEngine on
RewriteBase /

# if not https, redirect
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ignore any .cfm|.html|.asp|.ico files and certain directories
RewriteRule ^(php|images|css|js|xyz|(.*)\.html|(.*)\.asp|(.*)\.ico)($|/) - [L]

# parse the subdomain as a variable we can access
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^app
RewriteCond %{HTTP_HOST} ^([^.]+)\.[^.]+\.[^.]+$
RewriteRule ^(.*)$ index.php?sub=%1&path=$1 [L,QSA]