呃.. mod_rewrite 让我觉得自己很愚蠢。我只是还没想好。:/
我有这个网址:
http://example.com/a/name/
...我想在这里指出:
http://example.com/a/index.php?id=name
...作为参数name
传递给的内容在哪里。index.php
id
我尝试过的任何结果都会导致 404 或 500 .. :(
呃.. mod_rewrite 让我觉得自己很愚蠢。我只是还没想好。:/
我有这个网址:
http://example.com/a/name/
...我想在这里指出:
http://example.com/a/index.php?id=name
...作为参数name
传递给的内容在哪里。index.php
id
我尝试过的任何结果都会导致 404 或 500 .. :(
让你开始:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule ^/?a/([^/]+)/?$ /a/index.php?id=$1 [QSA,L]
如果一个重写教程不适合您,请尝试另一个.
编辑:index.php
根据 Gumbo 的建议排除
也许类似于
RewriteEngine on
RewriteBase /a/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php?id=$1 [L,QSA]
会成功的。
我建议你看看这个网址:
http://www.dracos.co.uk/code/apache-rewrite-problem/
提出的解决方案将起作用,但 URL 中解释了一些警告,主要是关于 ? 和 # 在 URL 本身中。