I am currently making a URL shortener site where I will be able to shorten links and then get the shortened URL and its unique id stored on the database. To access the shortened URL, I planned to add a slug to the URL making my URL look like this:
mysite.com/randomUrlId
But when I add a slug to my page (hosted here), it shows an error. I am very sure this can be done using the .htaccess
file but I am not sure about how to approach it.
How can we add dynamic slugs?
This is the .htaccess
file which I got by default:
# PHPVersion
#="php74"
AddHandler x-httpd-php74 .php
#-PHPVersion
# OptionsIndexing
#="1"
Options Indexes
IndexOptions FancyIndexing
#-OptionsIndexing
CodePudding user response:
I got it. It was more like a hacky solution but what I did is I added my main index.html
file to 404 error and now it works perfect. This is the line I added:
ErrorDocument 404 /index.html