I am trying to make a node have the alias "/libraries" but I get a Page Not Found error which looks to be returned before Drupal has fully bootstrapped (I don't get the usual Drupal 404).

I checked a few other sites and they seem to have the same issue. Is there some reason why I cannot use this alias in Drupal? Would it have anything to do with a "libraries" folder in the root of the project?

Edit: It does appear to be because I have a "libraries" directory in the docroot which contain various JS libraries for CKEditor and other modules that need them.

So what is the fix here? I assume if I change the directory to anything else, those plugin paths will break. I could add Libraries API maybe, but I don't know the status of that module, but it still means any module that has a libraries.yml file that looks for /libraries..../file.js still won't work.

In this actual case, /libraries is a View (or could wind up being a node with a View block on it) that lists all libraries in the system, and thats what I want the URL to be.

  • this is happening before Drupal is bootstrapped in .htaccess, RewriteCond %{REQUEST_FILENAME} !-d excludes existing directories getting to index.php
    – 4uk4
    Jan 29, 2018 at 22:09
  • Makes sense. So, am I stuck here?
    – Kevin
    Jan 29, 2018 at 22:10
  • 1
    @Kevin This worked for me some years back: drupal.stackexchange.com/questions/52882/…
    – Clive
    Jan 29, 2018 at 22:31
  • I tried to implement a rule that matched ^libraries/$ which resulted in an endless redirect loop - how did you get around that with profiles? Note that I only want to allow the alias /libraries for a node that lists all library locations in the city - other nodes have a Pathauto pattern of /libraries/[node:title] and seem fine as-is.
    – Kevin
    Jan 31, 2018 at 14:36

1 Answer 1


For anyone looking in the future, this will solve it.

Add this to your htaccess file:

# Allow the alias "/libraries" to work without breaking actual assets in the libraries directory.
RewriteRule ^libraries$ /index.php [L]

Just before this block:

  # Pass all requests not referring directly to files in the filesystem to
  # index.php.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

I also had to add an .htaccess file to the libraries directory. Inside of that, I had to do:

DirectoryIndex ../index.php
DirectorySlash off

Now I can create an alias for /libraries and not introduce and endless redirect loop, and physical assets (CKEditor plugins) can still be loaded correctly from this directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.