When you click to view a pdf file on a page the url is always this: http://yoursite.com/sites/default/files/myfile.pdf. You can modify this path in the field setting and add tokens, dates. But what if you wants the url to be simple and not give out the fact that this is a Drupal site. Can you change it to be this: http://yoursite.com/files/myfile.pdf. Does this require htaccess url rewrite or Apache redirects?
1 Answer
Go to this path /admin/config/media/file-system
, and change the public file system path.
It might be this, sites/default/files
, change it to files
.
Then create a writeable folder in your webroot called files.
This could also be done by adding this line in the settings.php file:
$settings['file_public_path'] = 'files';
Just note that this is only for local development if you want to deploy this change you might use the above solution and then export the configuration.
-
Thanks! I opened the settings.php and added this- $settings['file_public_path'] = 'files'; Apr 27, 2018 at 13:35
-
Nice, you just need to remember that the changes you make in the settings file will not de deployed. If you want this change to be deployed, then you my solution and then export configuration.– user72672Apr 27, 2018 at 17:42
-
I would like to be able to export this config, but how are changes in the the settings files exported, does a configuration file get created when you export?. We set are memory limit in the settings file. But we do this change right on the server in prod and dev. Apr 28, 2018 at 18:55
-
On a normal drupal setup the changes in the settings.php file is only for local use. Everything that needs to get imported to prod, either needs to be exported as configuration or set manually on the prod server. I hope that explains what you are asking.– user72672Apr 28, 2018 at 22:20
drupalSettings
library, in the browser console you can typeDrupal.settings
and see the object, heh. There are various ways.