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

refactor and fix nginx/htaccess config examples #302

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

stklcode
Copy link
Contributor

@stklcode stklcode commented Jul 7, 2024

hdd.htaccess (see #248):

  • simplify the code to generate our .htaccess config example
  • fix rewrite condition for empty query string
  • remove some redundant HTML escapes

Example output with GZIP enabled

# BEGIN CACHIFY
<IfModule mod_rewrite.c>
  RewriteEngine on

  # set hostname directory
  RewriteCond %{HTTPS} on
  RewriteRule .* - [E=CACHIFY_HOST:https-%{HTTP_HOST}]
  RewriteCond %{HTTPS} off
  RewriteRule .* - [E=CACHIFY_HOST:%{HTTP_HOST}]

  # set subdirectory
  RewriteCond %{REQUEST_URI} /$
  RewriteRule .* - [E=CACHIFY_DIR:%{REQUEST_URI}]
  RewriteCond %{REQUEST_URI} ^$
  RewriteRule .* - [E=CACHIFY_DIR:/]

  # gzip
  RewriteRule .* - [E=CACHIFY_SUFFIX:]
  <IfModule mod_mime.c>
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=CACHIFY_SUFFIX:.gz]
    AddType text/html .gz
    AddEncoding gzip .gz
  </IfModule>

  # Main Rules
  RewriteCond %{HTTP_ACCEPT} .*text/html.*
  RewriteCond %{REQUEST_METHOD} GET
  RewriteCond %{QUERY_STRING} ^$
  RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-content/cache)/.*
  RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
  RewriteCond /var/www/html/wordpress/wp-content/cache/cachify/%{ENV:CACHIFY_HOST}%{ENV:CACHIFY_DIR}index.html%{ENV:CACHIFY_SUFFIX} -f
  RewriteRule ^(.*) /wordpress/wp-content/cache/cachify/%{ENV:CACHIFY_HOST}%{ENV:CACHIFY_DIR}index.html%{ENV:CACHIFY_SUFFIX} [L]
</IfModule>
# END CACHIFY

hdd.nginx

  • only add gzip_static on; directive to nginx HDD example, if gzip is enabled

apc.htaccess

  • simplify the code to generate our .htaccess config example

apc.nginx

@stklcode stklcode force-pushed the fix/248-htaccess branch 2 times, most recently from 9b8e965 to 6204b63 Compare July 7, 2024 09:20
@stklcode stklcode marked this pull request as ready for review July 7, 2024 09:22
@stklcode stklcode changed the title refactor .htaccess example refactor and fix nginx/htaccess config examples Jul 7, 2024
@stklcode stklcode added the bug label Jul 7, 2024
@stklcode stklcode added this to the 2.4.0 milestone Jul 7, 2024
stklcode added a commit that referenced this pull request Jul 7, 2024
* simplify the code to generate config examples
* remove some redundant HTML escapes
* hdd.htaccess: fix rewrite condition for empty query string
* apc.nginx: remove STRONG tags which are not supported inside TEXTAREA
* hdd.nginx: only add "gzip_static" directive to nginx HDD example, if enabled
* memcached.nginx: remove "gzip_static" directive
* simplify the code to generate config examples
* remove some redundant HTML escapes
* hdd.htaccess: fix rewrite condition for empty query string
* apc.nginx: remove STRONG tags which are not supported inside TEXTAREA
* hdd.nginx: only add "gzip_static" directive to nginx HDD example, if enabled
* memcached.nginx: remove "gzip_static" directive
Copy link

sonarcloud bot commented Jul 7, 2024

@stklcode stklcode self-assigned this Jul 7, 2024
@stklcode stklcode merged commit f9eaee6 into develop Aug 4, 2024
15 checks passed
@stklcode stklcode deleted the fix/248-htaccess branch August 4, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant