webp-express
webp-express copied to clipboard
Feature request: make redirects independent of server name
Hi there,
We have a setup where the contents of the acceptance site are copied to the live site. With the .htaccess
rules containing the server name of the acceptance site, the live site breaks.
This is easily remedied by replacing the current site url in the .htaccess
rules with %{SERVER_NAME}
. Would you consider this?
Otherwise, our live site will break the next time the .htaccess
rules need to be updated. :)
Here is an example .htaccess
file, tim.concept.vevida-test.nl
is the URL of my development site:
# Rules for handling requests for source images
# ---------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect to existing converted image in cache-dir (if browser supports webp)
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} (?i)(/data/www/tim.concept.vevida-test.nl/html/wp-content/uploads/)(.*)(\.jpe?g|\.png)$
RewriteCond /data/www/tim.concept.vevida-test.nl/html/wp-content/webp-express/webp-images/uploads/%2%3.webp -f
RewriteRule (?i)(.*)(\.jpe?g|\.png)$ /wp-content/webp-express/webp-images/uploads/%2%3\.webp [T=image/webp,E=EXISTING:1,E=ADDVARY:1,L]
# Redirect images to webp-on-demand.php (if browser supports webp)
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule (?i).*(\.jpe?g|\.png)$ /wp-content/plugins/webp-express/wod/webp-on-demand.php?xwp-content-rel-to-plugin-dir=x../&xsource-rel-htaccess=x$0&htaccess-id=uploads [E=WE_WP_CONTENT_REL_TO_PLUGIN_DIR:../,E=WE_SOURCE_REL_HTACCESS:$0,E=WE_HTACCESS_ID:uploads,NC,L]
# Make sure that browsers which does not support webp also gets the Vary:Accept header
# when requesting images that would be redirected to webp on browsers that does.
<IfModule mod_headers.c>
<FilesMatch "(?i)\.(jpe?g|png)$">
Header append "Vary" "Accept"
</FilesMatch>
</IfModule>
</IfModule>
# END WebP Express
Since I reported this issue, it seems that the .htaccess rules are updated as soon as I enter the WP-admin. So altering the .htaccess-files manually is not an option anymore, since the changes will be overwritten.
The header of the .htacces files mentiones:
# The directives (lines) between `BEGIN WebP Express` and `END WebP Express` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
However, neither WordPress nor WebP Express provide such a filter. If you will not do my above request, could you at least provide a filter so I can change the rules through that?