我想传递(而不是重定向)这样的东西:
http://www.example.com/(带 / 可选)传递给脚本 http://www.example.com/index.php
http://www.example.com/foo/(带 / 可选)传递给脚本 http://www.example.com/index.php?nav=foo
http://www.example.com/foo/bar(带有/可选)传递给脚本 http://www.example.com/index.php?nav=foo&subnav=bar
此外,我想使用与上述相同的参数将子域http://testumgebung.example.com传递给http://www.example.com/testumgebung.php 。
我只是设法执行以下操作,但它会将浏览器栏中的 url 重写为传递的位置,并且不会像以前那样保留 url:
RewriteCond %{HTTP_HOST} ^testumgebung\.maskesuhren\.de
RewriteRule ^(.*)$ http://www.maskesuhren.de/$1/testumgebung.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[^/]+/?$
RewriteRule ^([^/]*)/?$ index.html?nav=$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /.*/.*
RewriteRule ^([^/]*)/([^/]*)$ index.html?nav=$1&subnav=$2 [R,L]