So I haven't quite figured out the proper structure to use within my .htaccess file for what I am looking to achieve.
What I would like to have happen is any javascript files that are called from a folder (and only that folder) are generated by a php file. I'm not looking to have a .php extension or create multiple files for this.
An example is
https://www.domain.com/loads/923as0d9f89089asd.js
Would then be sent to something like:
https://www.domain.com/loads/js.php
Not looking to use a $_GET method on the php either. Basically the php file detects the file name and then does what it is supposed to do from there.
What would be the best way to set this up within an .htaccess file?
Thanks!
Inside loads/.htaccess
you can use this rule:
RewriteEngine On
RewriteBase /loads/
RewriteRule ^[\w-]+\.js$ js.php [L,NC]
Inside your js.php
you need to use $_SERVER["REQUEST_URI"]
to get original JS filename and serve the content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With