Skip to main content
7 votes
Accepted

How to modify .htaccess to serve brotli compressed static assets over gziped ones?

Give this a try # Rules to correctly serve gzip compressed CSS and JS files. # Requires both mod_rewrite and mod_headers to be enabled. <IfModule mod_headers.c> # Serve brotli compressed CSS ...
mikeytown2's user avatar
  • 8,322
6 votes

D8 doesn't create .htaccess for private file system path

This is a better .htaccess to use: # Turn off all options we don't need. Options -Indexes -ExecCGI -Includes -MultiViews # Set the catch-all handler to prevent scripts from being executed. SetHandler ...
hotwebmatter's user avatar
  • 2,122
5 votes

How to prevent executing .php files in sites/default/files directory for nginx+php7.0-fpm?

This is what works for nginx and only targets files directory: location ~ /files/.*\.php$ { return 403; } This is more generic and wont let any php file in a directory execute directly: ...
Gerald Melendez's user avatar
5 votes
Accepted

Getting error 'Redirects to external URLs are not allowed by default'

If you still haven't figured this out, check this comment on d.o: https://www.drupal.org/project/drupal/issues/2612160#comment-11767977 It suggests a workaround by removing the subdir from the script ...
kufeiko's user avatar
  • 435
5 votes
Accepted

How are clean URLs with 200 response codes being managed without doing a RewriteMap?

The Apache mod rewrite module is used. /some/path is rewritten internally by Apache to index.php?q=some/path [Credit: mpdonadio]. index.php bootstraps Drupal. Drupal determines if it is able to ...
Jaypan's user avatar
  • 17.8k
3 votes

Create a general rewrite rule in .htaccess

I think your rewrite collides with the other rewrites in drupal standard .htaccess. Try a redirect. The redirect will be executed right away and the rest of .htaccess will no longer be processed. And ...
4uk4's user avatar
  • 101k
3 votes
Accepted

After migration, impossible to logging from the remote server, error 'You are not authorized to access this page"

According to kingfisher64 in "Access denied" "you are not authorized to access this page" error ??? Just in case somebody stumbles over this issue the solution for me was in settings.php. I had ...
No Sssweat's user avatar
  • 31.4k
3 votes

"You don't have permission to access / on this server"

I can't imagine Drupal 8 is supposed to have this done on every installation. You're right, it only needs to be done in .htaccess where altering the web server config isn't an option (think shared ...
Clive's user avatar
  • 168k
3 votes

how to stop annoymous users to login in drupal

There is the restrict by IP module, which can solve the use-case pretty fast. For the second part, depending on if you are in 7 or 8, you would want to write code to handle a request to either of the ...
Kevin's user avatar
  • 28k
3 votes
Accepted

Why are there .htaccess and php files in ./sites/default/php/twig

The PHP files are compiled Twig templates and the .htaccess file protects them from public access. You can switch off the caching of compiled twig templates by setting this service parameter to FALSE. ...
4uk4's user avatar
  • 101k
3 votes

Two sites on the same server don't work

Check both site's .htaccess files and find the lines where it says RewriteBase etc. Your first site's .htaccess needs: # If your site is running in a VirtualDocumentRoot at http://example.com/, #...
leymannx's user avatar
  • 18.6k
3 votes
Accepted

Google Page Speed Insights recommends Leverage browser caching

As these files ain't located on your server you can't do anything about it except wondering why Google Page Speed isn't smart enough to distinguish between on-site resources and external resources. Or ...
leymannx's user avatar
  • 18.6k
3 votes

How do I redirect a domain but keep the URL structure?

Your second variant is close to the goal. But it needs some edits. Firstly, you should escape all dots in RewriteCond, so it will be RewriteCond %{HTTP_HOST} ^example\.co\.uk$ [NC] Secondly you need ...
Eugene Bocharov's user avatar
3 votes
Accepted

Patching docroot htaccess: file not found

Look your patch already has the path to web/ in it: --- a/web/.htaccess +++ b/web/.htaccess Just remove the cd web && and adjust the path to the patch accordingly. "post-drupal-scaffold-...
leymannx's user avatar
  • 18.6k
3 votes

How to restrict access to specific php file to only athenticated users

.htaccess won't help with this; Apache doesn't know what an authenticated Drupal user is, and there's no easy way to grant it that knowledge. Fortunately there's a much better option: Create a route ...
Clive's user avatar
  • 168k
3 votes
Accepted

How do I avoid overwriting the .htaccess file when I use the Compose command?

Both .htaccess and robots.txt are a part of Drupal core, they are called "Scaffold Files". When you do composer update it will download the repository version of these files. You have to re-...
milkovsky's user avatar
  • 5,364
3 votes
Accepted

Website doesn't load properly from htdocs/web

This is very limited shared-hosting, no control panel and no way to edit apache's configs, only .htacess files accessible in htdocs Look for a new hosting company, until then you can use the legacy ...
4uk4's user avatar
  • 101k
2 votes

How to check if Drupal user is logged in via htaccess?

Drupal does store the session value in the cookie variable after the user is logged in. However, the name of this cookie is not fixed. It is basically a string that comes from the value returned by ...
AjitS's user avatar
  • 10.9k
2 votes

Problem with SSL certificate

There are some known issues with Drupal 7.x in some server configurations particularly around PHP 5.6 and OpenSSL 0.9x due to changes in how PHP verifies SSL certificates. Acquia has some notes about ...
acrosman's user avatar
  • 2,728
2 votes

redirect whole site to HTTPS

The example from @rjkunde didn't work on my local Lando based drupal development environment, the browser gave me the error message: "The page isn’t redirecting properly". The drupal ...
LarS's user avatar
  • 619
2 votes
Accepted

Only front page works

I believe the problem was due to the location of my .htaccess file. (The main problem was the Clean URLs.) My original location was /var/www/drupal/sites/default/files; after, I moved it to /var/www/...
Kemal Tezer Dilsiz's user avatar
2 votes

Create a general rewrite rule in .htaccess

Rewrites this code for your problem in .htaccess. The code will work for any string in between reading_ and .html RewriteEngine On RewriteRule ^reading_(.*)\.html$ http://www.server.com/reading/$...
Ashish Deynap's user avatar
2 votes
Accepted

How to fix my Rewriterule in .htaccess to transparently redirect any domain alias?

This worked: I had to use the ?q= inside the last rewriterule like this: RewriteRule ^/?$ ?q=landingpage/%1-%2 [L]
Yuri's user avatar
  • 618
2 votes
Accepted

Where is the .htaccess file?

If you download Drupal from here, there is the .htaccess file in main directory. How do you downloaded Drupal source code?
arrubiu's user avatar
  • 3,294
2 votes

Where is the .htaccess file?

I executed the command you quoted, and I got the following files. (I executed ls -alF in the directory where Drupal 8.3.0 was copied from Drush.) -rw-rw-rw- 1 kiamlaluno kiamlaluno 262 Apr 6 02:...
avpaderno's user avatar
  • 97.7k
2 votes

Two sites on the same server don't work

As said previously, check your HTACCESS on both sites, and your apache virtual host. In theory, you can imbricate websites... But it's not recommended and not easily maintainable. But the simpler and ...
JudaPriest's user avatar
2 votes

Two sites on the same server don't work

First of all: You might want to check the logs: both sites logs + server logs + db logs. There got to be some error code somewhere. Here's a list of things you can try: Use different admin users ...
Tritof's user avatar
  • 661
2 votes

Serving Drupal from within a sub-directory of my web root

You have to edit the nginx virtual host file of your website. You'll usually find it at /etc/nginx/sites-available/yoursitename.vhost. Open it with write permissions, and edit root directive at the ...
Kojo's user avatar
  • 3,513
2 votes
Accepted

.htaccess rewrite doesn't work

The rewrite rule will not work because page is not a valid path on the server. By default Drupal rewrites all requests into index.php. When you rewrite to page apache will expect a path page on the ...
anoopjohn's user avatar
  • 948

Only top scored, non community-wiki answers of a minimum length are eligible