Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am looking a good solution. I have some pdf files stored on azure blob storage and I like to implement a way so when one of the pdf file name change and if someone try to access the old pdf file name I want them to redirect to the new pdf file and send 301 redirect status. correct me if i am wrongI believe I can't do this using .htaccess since these files will rename dynamically and I want to implement a solution so 301 redirect with the new file name will occurred automatically. I don't want to maintain htaccess file. Any advice or a good solution?

What I have tried:

one solution i was think to create an node api and control url that way but i just cant wrap my head around how to implement this, any help please.
Updated 2-Jul-20 13:03pm

Somehow you are going to need a list of the filenames, and what the new filenames are.

Once you have that "list", you could add in code that when there is a change in the list; you could automatically update the .htaccess file with the new information.

What I have in place is a custom 404 handler; and if a file is not found it will check a database table to see if there is a redirect in place for it and generate a 301 if there is.
Share this answer
code-destroyer 2-Jul-20 20:54pm    
Hello @MadMyche - Thanks. I am avoiding updating .htaccess file because there are going to be hundreds of files and more, and then every time a file renames then i am afraid it will going to increase the size of the file too big in the future; that is why i am trying to stay away using htaccess file.

I do like you idea regarding a custom 404 handler and if a file is not found it will check a database table. I am very new to this, are you able to provide me some code example and guidance how you have exactly implemented customer 404 handler?

MadMyche 3-Jul-20 0:23am    
Unfortunately that code is integrated into a proprietary system and subject to Non-Disclosure.
Basically though; it follow the steps I gave above, which could easily be done in most programming languages
301 is a type of redirection code . It is mainly used for redirecting a page to another
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900