简体   繁体   中英

Automatically Rewrite URL for Dynamic content in URL : PHP

I am trying to get the user details based on their email id so, When Using GET

My URL Looks Like this :

http://localhost/test/profile.php?uid=test@example.com

is there any way that when I send the the Get Request My URL will automatically look like this.

http://localhost/test/profile/test@example.com

NOTE : The uid value changes if we fetch different email

There is no automatic way, and rewrite rules won't help you either: they help to map an incoming URL (coming from the browser) into the proper URL needed for your application.

But you are looking for the other way: generate the proper URL that should be shown in the browser's URL bar. This needs to be done in your application by hand - and how to do this is not explainable while you haven't shown your code. A pretty generalized way could look as following:

<form action="test/profile/<?php echo $email; ?>">

Try this:

RewriteEngine on
RewriteRule ^test/profile/(.*)$ /test/profile?uid=$1

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