: Rewrite and hide page ID from URL I am working with the following on a football website and when a user clicks an event they get the following URL format: /live/1/event-name.html Currently
I am working with the following on a football website and when a user clicks an event they get the following URL format:
/live/1/event-name.html
Currently the number in the URL represents the ID number of the page, but ideally I'd like to hide this so it returns the following URL:
/live/event-name.html
How can I rewrite and hide the page ID number in the URL path completely.
More posts by @Chiappetta492
1 Comments
Sorted by latest first Latest Oldest Best
In your case, use actual event names instead of ID numbers as unique values both in the URL and any database you are running in the back-end of your website.
Your rewrite rule probably (assuming your server is apache) has a line like this:
RewriteRule ^live/([0-9]+)/(.*).html$ processevent.php?ID=&Name= [L]
Change that line to:
RewriteRule ^live/(.*).html$ processevent.php?Name= [L]
Then again, you'll want to replace .* with a stricter regex expression to ensure appropriate characters are in the URL. Maybe something like this will work better for you:
RewriteRule ^live/([A-Za-z0-9-]+).html$ processevent.php?Name= [L]
In your back-end script, access whatever database your script uses and use the event name to seek relevant data required to process the page. You may want to consider making the event name the primary key of the database table.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.