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

Can you explain in details pushing to live server? #3

Open
mateostabio opened this issue Jun 2, 2019 · 4 comments
Open

Can you explain in details pushing to live server? #3

mateostabio opened this issue Jun 2, 2019 · 4 comments

Comments

@mateostabio
Copy link

mateostabio commented Jun 2, 2019

So this plugin seems awesome and exactly what I need it for. It works perfectly in my local build. But as soon as I push everything to the server. My CSS and JS breaks and I get 404s on the files. I tried adding the stuff in the .htaccess but no luck - still gives me 404 errors on those versioned files and also gives me 404 errors on other files that don't even use craft.stamp.er.

HTML
<link rel="stylesheet" href="{{ craft.stamp.er('/assets/css/style.css') }}">

OUTPUT
<link rel="stylesheet" href="/assets/css/style.1559499637.css">

OPEN STYLESHEET IN NEW TAB
Error 404 page

HTACCESS

<IfModule mod_expires.c>
	# Rewrites asset versioning, ie styles.1399647655.css to styles.css.
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.+)\.(\d{10})\.(js|css)$ $1.$3 [L]  # /assets/build/js/scripts.1399647655.js
	# RewriteRule ^(.+)/(\d{10})/(.+)\.(js|css)$ $1/$3.$4 [L]  # /assets/build/js/1399647655/scripts.js
</IfModule>
@mateostabio
Copy link
Author

I managed to get it working by refreshing everything, clearing the cache, and changing the live server htaccess file to force https and www


<IfModule mod_expires.c>
	# Rewrites asset versioning, ie styles.1399647655.css to styles.css.
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.+)\.(\d{10})\.(js|css)$ $1.$3 [L]  # /assets/build/js/scripts.1399647655.js
	# RewriteRule ^(.+)/(\d{10})/(.+)\.(js|css)$ $1/$3.$4 [L]  # /assets/build/js/1399647655/scripts.js
</IfModule>


<IfModule mod_expires.c>
   RewriteEngine On
   RewriteCond %{HTTPS} off
   # First rewrite to HTTPS:
   # Don't put www. here. If it is already there it will be included, if not
   # the subsequent rule will catch it.
   RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
   # Now, rewrite any request to the wrong domain to use www.
   # [NC] is a case-insensitive match
   RewriteCond %{HTTP_HOST} !^www\. [NC]
   RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>


<IfModule mod_rewrite.c>
	RewriteEngine On

	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d

	RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
	RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>

@oconnedk
Copy link

Sounds like this issue can be closed, then, since it was a config issue on your production server?

@JialuZhang
Copy link

@mateostabio

In your first posted configuration, the line started with: "RewriteRule" are misconfigurations, and adding them to your system will not change any system behavior.

"RewriteEngine" has to be explicitly set to on, then "RewriteRule" will be used in Apache.

Related Apache source code snippet:

run_rewritemap_programs(server_rec *s , apr_pool_t *p){
if (conf->state == ENGINE_DISABLED) { // usage of "RewriteEngine"
  return APR_SUCCESS; // early return
rewritemap_program(...); // usage of "RewriteRule" 
}

@JialuZhang
Copy link

@oconnedk

I think this is a misconfiguration. User cannot have the same understanding as Apache developers. (which is more than okay)

The only way to fix the misconfiguration is to hack the Apache source code. This is not feasible and 100% not ideal for users.

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

3 participants