简体   繁体   English

如何使URL看起来像“ / lobby / 1”而不是“ /lobby.php?id=1”?

[英]How do I make a URL to look like “/lobby/1” instead of “/lobby.php?id=1”?

I want to make a URL to look like this: 我想使一个URL看起来像这样:

http://example.com/lobby/1

instead of 代替

http://example.com/lobby.php?id=1

I know I can do this with .htaccess but I couldn't find a way how. 我知道我可以使用.htaccess做到这一点,但我找不到方法。

There are several already answered questions, such as .htaccess rewrite "/book.php?id=1234" to "/book/1234" 有几个已经回答的问题,例如.htaccess将“ /book.php?id=1234”重写为“ / book / 1234”

RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^ lobby\.php$ /lobby/%1? [L]

You can use the following : 您可以使用以下内容:

 RewriteEngine on

RewriteCond %{THE_REQUEST} /lobby\.php\?id=([0-9]+)
RewriteRule ^ /lobby/%1? [NC,L,R]

RewriteRule ^lobby/([0-9]+)/?$ /lobby.php?id=$1 [NC,L]

try this! 尝试这个!

in htaccess file write this 在htaccess文件中写这个

RewriteEngine on 在RewriteEngine上

RewriteRule ^lobby/([0-9]+) lobby.php?id=$i RewriteRule ^ lobby /([[0-9] +)lobby.php?id = $ i

and in you html or php file call lobby.php?id=$i 并在您的html或php文件中调用lobby.php?id = $ i

page by 逐页

lobby/$i 大堂/ $ i

you are done. 你完成了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM