删除?来自链接

时间:2014-03-27 16:26:33

标签: php .htaccess web

基本上我的大部分链接都是

localhost/?login
localhost/?register
localhost/?admin

I want to make them look like:

localhost/login
localhost/register
localhost/admin

等。但我记得之前我删除了?从那以后,我就不记得了。 无法通过谷歌找到任何帮助,但它可能在那里。

我也可以如何制作

localhost/?login&something=123

看起来像

localhost/login/something=123
localhost/login/something/123

1 个答案:

答案 0 :(得分:1)

您可以使用.htaccess

RewriteRule ^([^/]+)/?$ /?$1 [L]
RewriteRule ^([^/]+)/([^/]+)/?$ /?$1&$2 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /?$1&$2=$3 [L]

以上内容将为您进行以下转换:

localhost/login               => localhost/?login
localhost/login/something     => localhost/?login&something
localhost/login/something/123 => localhost/?login&something=123