[英]Php Rewrite Url .htaccess file
The problem I m facing that I am receiving an id from url and showing it simply 我面临的问题是我从URL接收到一个ID并简单地显示它
http://localhost/test/?username=bingo123
http:// localhost / test /?username = bingo123
Its working fine and shows the result 它的工作正常,并显示结果
But I want that I should be able to write like 但我希望我应该能够像
http://localhost/test/bingo123 .
http:// localhost / test / bingo123 。
I tried to make .htaccess
file and but it does not work and shows 我试图制作
.htaccess
文件,但它不起作用并显示
The requested URL /test/bingo123 was not found on this server
在此服务器上找不到请求的URL / test / bingo123
Rewriteengine on
Rewriterule ^([a-zA-z]+)$ index.php?username=$1
I want to know that what should i change make in .htaccess
file or some other settings in Wamp to run the script and where should I save .htaccess
so that It works fine .Here "test" the folder name where all php files are there and how to save the .htaccess
file as it does not allow it to save without first name. 我想知道应该更改
.htaccess
文件中的内容或Wamp中的其他设置以运行脚本,以及应该在哪里保存.htaccess
以便它能正常工作。在此“测试”所有php文件所在的文件夹名称以及如何保存.htaccess
文件,因为它不允许没有名字的情况下保存。
Thanks in advance. 提前致谢。
Try like this 这样尝试
RewriteEngine On
RewriteRule ^test/([^/]*)$ /test/?username=$1 [L]
Myabe Helpful Myabe有用
RewriteRule ^test/([a-zA-Z]+)$ test.php?username=$1 [L]
RewriteRule ^test/([a-zA-Z]+)/([a-zA-Z]+)$ test.php?username=$1/$2 [L]
RewriteRule ^test/([a-zA-Z]+)/([0-9]+)$ $ test.php?username=$1[L]
RewriteEngine On
RewriteRule ^test/([a-zA-Z0-9-=_.]+)$ test.php?username=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.