【发布时间】:2013-10-22 14:44:13
【问题描述】:
我想传递(而不是重定向)这样的东西:
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]
【问题讨论】:
标签: .htaccess mod-rewrite