I would like to do if somebody adds a hex value at the end of the URL, I can show them a certain page.
For example, say I have colors.com, I would like it so if somebody want to go to colors.com/FF0000, it would display that hex on the page. Is it possible to grab it from the URL and display it although I would like it to be hex values only.
Remove certain letters and special characters so somebody can’t just use text.
Hope that makes sense.
You would need to use your web server’s URL rewriting to match patterns which look like hex colors (6 letters A-F and digits 0-9) and route accordingly.
Apache mod_rewrite example to silently rewrite
example.com/AA00FFtoexample.com/index.php?color=AA00FF:In your PHP script
index.php, retrieve it from$_GET['color']. You will need to validate it in PHP for that regex as well. Otherwise, you risk XSS attacks:I’m not saying this is a good idea, but to set the body color, you can then just do: