: Possible to drop the original query parameters entirely in a rewritten URL? Original URL looks something like domain.com/filename.php?id1=333&id2=444. Desired rewritten URL is something like domain.com/my-rewritten-url.
Original URL looks something like domain.com/filename.php?id1=333&id2=444.
Desired rewritten URL is something like domain.com/my-rewritten-url.
I can imagine creating a lookup table with columns for the ids and a column for the rewrite string, but is this realistic/practical?
More posts by @Nimeshi995
1 Comments
Sorted by latest first Latest Oldest Best
This is very possible to implement. I have implemented it myself. It requires more than a rewrite rule though. It requires you to change the code that runs your web application. Here is how I have made it work:
A request comes in for /my-rewritten-url
A rewrite rule forwards it to `/filename.php?path=my-rewritten-url
The PHP script does a database query to get the parameter string (id1=333&id2=444) and the file name that should handle the request (show-this-page-type.php)
It parses that parameter string and puts the values into the parameter map
It dispatches the request to show-this-page-type.php
The downsides are:
It adds an extra database query (caching can help)
It requires that your website be powered by a single script that may have to dispatch requests out to other scripts
It breaks analytics that are rely on the existence of parameters in the URLs or the name of the script. (It is much harder to determine page type, for example.)
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.