简体   繁体   中英

Php Rewrite Url .htaccess file

The problem I m facing that I am receiving an id from url and showing it simply

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 .

I tried to make .htaccess file and but it does not work and shows

The requested URL /test/bingo123 was not found on this server

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.

Thanks in advance.

Try like this

RewriteEngine On
RewriteRule ^test/([^/]*)$ /test/?username=$1 [L]  

Myabe Helpful

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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