Simplify ddev .htaccess handling

This commit is contained in:
Alex P 2022-05-06 10:39:41 +03:00
parent 29aff60d27
commit b84177b61c
3 changed files with 17 additions and 21 deletions

View file

@ -14,21 +14,6 @@ if [ "${WP_MULTISITE}" = "true" ]; then
--admin_email="${ADMIN_EMAIL}" \
--skip-email
cat << 'EOF' >> ".htaccess"
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
EOF
readarray -d , -t slugs <<< "${WP_MULTISITE_SLUGS},"; unset "slugs[-1]";
for slug in "${slugs[@]}"; do
if [ ! -z "${slug}" ]; then

View file

@ -0,0 +1,16 @@
#!/bin/bash
cat << 'EOF' >> ".htaccess"
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
EOF

View file

@ -1,9 +1,4 @@
#!/bin/bash
# Needed for generating the .htaccess file
echo "apache_modules:
- mod_rewrite
" > wp-cli.yml
wp rewrite structure '/%postname%'
wp rewrite flush --hard
wp rewrite flush