Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.htaccess is emptied during the initial setup - as intended? #792

Open
czka opened this issue Jan 24, 2023 · 2 comments
Open

.htaccess is emptied during the initial setup - as intended? #792

czka opened this issue Jan 24, 2023 · 2 comments

Comments

@czka
Copy link

czka commented Jan 24, 2023

The contents of /usr/src/wordpress/.htaccess in wordpress:latest (6.1.1-php8.0-apache as of writing this) are the following:

$ docker run -ti --entrypoint '' wordpress:latest cat /usr/src/wordpress/.htaccess
# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

During the initial docker run --name wordpress <your options go here> wordpress:latest, the ENTRYPOINT script copies /usr/src/wordpress/.htaccess as it is into /var/www/html/:

$ docker exec wordpress /bin/sh -c "cat /var/www/html/.htaccess"  
# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

After I open my WP page in a browser and complete the initial setup, I notice that all those rewrite settings are now gone:

$ docker exec wordpress /bin/sh -c "cat /var/www/html/.htaccess"
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.

# END WordPress

Is that as intended?

@tianon
Copy link
Member

tianon commented Jan 24, 2023

I believe so, yes -- I think WordPress itself will add some of these back if you set up permalink settings? I don't recall the specifics exactly. 😅

@tianon
Copy link
Member

tianon commented Jan 24, 2023

However, that does probably mean we could adjust how we handle .htaccess 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants