mardi 1 juin 2021

How to manipulate URL with .htaccess for PHP?

My goal is to manipulate the URL bar, so it would be simpler for users.

Im using htaccess and want to manipulate a URL

Current URL is: localhost/test/htdocs/invite?code=AB2A

I want the URL to be: localhost/test/htdocs/invite/ABAC

How could I use htaccess to accomplish this? I want the user to be able to type in localhost/test/htdocs/invite/ABAC and for it to work with my code, because currently they have to write localhost/test/htdocs/invite?code=AB2A

I am currently using this code:

RewriteCond %{QUERY_STRING} (^|&)code=([^.?]+)($|&)
RewriteRule ^test/htdocs/invite\.php$ /test/htdocs/invite/([^.?]+)? [L,R=301]

However, it says 404 Not Found




Aucun commentaire:

Enregistrer un commentaire