我想通过(不重定向)这样的事情:
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]
您要摆脱R
最后2条规则中的:
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 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /.*/.*
RewriteRule ^([^/]*)/([^/]*)$ index.html?nav=$1&subnav=$2 [L]
在R
方括号告诉mod_rewrite的将浏览器重定向,从而改变在浏览器的地址栏中的网址。。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句