user5922518
user5922518

Reputation:

htaccess -> Rewriting a request

I'm going to try and make this as simple as possible, I have a POST form that sends information called $searchid, I want to redirect it to look like a directory

I want to take the following information: (Server, folder, file, post)

localhost/shorts/profile.php?searchid=12345

And I want to make it look like (Server, fakefolder(id), fakefolder(post))

localhost/id/12345/

Also, is there A way to incorporate the sitename, as all the htaccess ive seen before hasnt had it and it's been showing the entire path from C drive.

Upvotes: 1

Views: 27

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

In htaccess in the root :

RewriteEngine on


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

This will rewrite

  • /id/numbers

to

  • /sports/profile.php?searchid=numbers

and allow you to access the page /sports/profile.php?searchid=numbers using the clean url /id/numbers .

Upvotes: 1

Related Questions