Disable automatic link rewriting for downloads not working
-
I have the following problem – didn’t notice it at first and it only happens on secondary languages…. I’m using a plugin (s2member) for premium content – and to link to protected downloads the link looks like e.g.
https://www.velomap.org/?s2member_file_download=odbl/velocongo-democratic-republic_macosx.7z
No qtranslate-x will change this to e.g.
https://www.velomap.org/de/?s2member_file_download=odbl/velocongo-democratic-republic_macosx.7zwhich will in turn end up on the frontpage/homepage instead of doing the download. If the user switches to english/first language then everything is fine.
I do not know why this link is rewritten, .7z should be expemted from translation. I tried changing all options in the plugin and also adding .7z manually to the exemption list – but I cannot get it to work…
-
— I think the problem has to do something with the automatic conversion!
(but even converting back to the old format – does not help q-translate-x to handle the downloads fine).As I noticed the problem too late – and restore the old database. I now converted to the old notation, disabled qtranslate-x and reenabled mqtranslate.
(I tried going back to qtranslate-x v3.1 but that did not solve the problem like i first thought).
Push Up —
Some more things.
It does not have to do anything with conversion. However I found out a pretty strange behaviour.I run my test-site with a separate database/files unter domain/testX/ – and on my test-site the download links are fine. On my main site however the download links break as soon as the language is switched to a secondary language.
All options in qtranslate-x are the same, the page also has the same content. I disabled more or less all other plugins – but it doesn’t help.
Rewrite rules in nginx.conf are the same. I’m really left a bit clueless why qtranslate-x works fine on my test-sites – but not on my production sites.
Also adding setlang=no doesn’t work:
https://www.velomap.org/?s2member_file_download=odbl/velolithuania_macosx.7z&setlang=no
as well as incorrect of course
https://www.velomap.org/?s2member_file_download=odbl/velolithuania_macosx.7z?setlang=no
will just redirect me to homepage..I have also tried to fix it by resetting all options – doesn’t change anything.
Just for reference – all somehow relevant content from my nginx.conf – maybe it is related to something here?
(note on test3 testdomain it works, but on plain domain it doesn’t…)server { server_name openmtbmap.org www.openmtbmap.com openmtbmap.com openfreemap.org openfreemap.com www.openfreemap.org www.openfreemap.com www.openmtbmaps.com openmtbmaps.com; rewrite ^ https://openmtbmap.org$request_uri? permanent; } server { listen 80; listen [::]:80; listen 443 ssl spdy; listen [::]:443 ssl spdy; spdy_headers_comp 1; # Add perfect forward secrecy ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; server_name openmtbmap.org; root /srv/www/htdocs; #access_log /var/log/nginx/host.access.log main; if ($http_user_agent !~ FeedBurner) { set $test "${test}F"; } location / { try_files $uri $uri/ /index.php; # does the requested file exist exactly as it is? if yes, serve it and stop here # if (-f $request_filename) { break; } # Sets the default type to text/html so that gzipped content is served # as html, instead of raw uninterpreted data. # default_type text/html; } location /test3/ { try_files $uri $uri/ /test3/index.php; # does the requested file exist exactly as it is? if yes, serve it and stop here # if (-f $request_filename) { break; } # Sets the default type to text/html so that gzipped content is served # as html, instead of raw uninterpreted data. # default_type text/html; } # Protecting s2-member-files folder location /wp-content/plugins/s2member-files { deny all; } # Add trailing slash to */wp-admin requests. rewrite /wp-admin$ $scheme://$host$uri/ permanent; # Add trailing slash to */wp-login requests. rewrite /wp-login$ $scheme://$host$uri/ permanent;
I know nothing about this 🙂
Question, do you use the code in both cases with the same content?
If so what happens when you remove the block location /test3/ in your plain site?
As I said here I know nothing about.
Success
Well basically the /test3 block is identical to the / block. It will only be used if a location cannot be found. So if the server is getting the request http://www.example.com/test3/filenotexist.php it would redirect to http://www.example.com/test3/
instead of redirecting to http://www.example.com/ or showing 404.On apache the redirect would be included in .htaccess – but that does not exist on nginx – hence the redirection rules are used.
Essentially for an Apache host the identical entry would be:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /test3/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /test3/index.php [L] </IfModule> # END WordPress
So maybe I guess that some of the redirection rules in qtranslate-x are incorrect and fail on / but work if using a subdomain – at least for nginx servers. There must be some error in the sourcecode of qtranslate-x that wasn’t there in qtranslate / mqtranslate. As written – this only happens if the language cookie is set to a secondary language (first language without /XX/ language code).
For me to switch to Apache from nginx would be a bit cumbersome, as I have all my sites using https:// and I haven’t configured the certs in apache, but I do guess the error will also happen on apache servers.
(I’ll give it a try now if I manage to get apache running using https – but I’m not sure if I do. The config of that pretty complicated).The plugin affected that I use is s2member:
https://wordpress.org/plugins/s2member/(I think for testing installing it, then putting a file into /wp-content/plugins/s2member-files/examplefile.exe ) and trying to reach
http://www.domain.com/?s2member_file_download=examplefile.exe
using an admin account should work without any further setting up of s2member. Then primary language should work, but secondary languages will redirect to domain.com instead of allowing to access the file. It’s just superstrange why it works on subdomain/subfolder installs – I would have guessed it doesn’t work at all no matter how wordpress is installed.No I didn’t. I was using 3.2.9 from wordpress.org repositories. But it’s the same on 3.2.9.5
BTW – I noticed something rather strange on the cookie function. If I have no cookie – and surf to my website – it will use domain.com (if I have the same language setup). I can then surf the site in the given language. If I then however surf once to domain.com/de/ then I get the german coookie – and will always be redirected to /de/ even if I try to surf to domain.com/examplesite/ I will endup at domain.com/de/examplesite/ until I use the language switcher widget. So qtranslate-x does not set a language cookie for default language it seems to me (at least if using “Hide URL language information for default language”. I would suppose also for default language a cookie should be set to offer consisten behaviour?
checked the Cookie settings under Languages – Advanced Settings?
Ah – I just got it. I can change the cookie by going to domain.com/en/ manually. Then the cookie will be set back to english and I end up at domain.com/
I have none of the cookie options set. BTW – it is clear that qtranslate-x does something to the download link before s2member can operate. Those download links should redirect non logged in users to the checkout page. That works fine for English. In secondary /de/ lanugage – non logged in users instead end up on the frontpage. So I would guess the plugin doesn’t matter at all, because qtranslate-x is catching the request first.
Just for reference – I send this to gunu also by email – so for everyone else. Redirection path working above, non working below (found out using chrome redirect plugin).
Working – english cookie – primary language.
https://www.velomap.org/?s2member_file_download=odbl/velodenmark_macosx.7z
302: Temporary redirect to https://www.velomap.org/support/membership/?_s2member_vars=file..level..1..file..odbl%2Fvelodenmark_macosx.7z..Lz9zMm1lbWJlcl9maWxlX2Rvd25sb2FkPW9kYmwvdmVsb2Rlbm1hcmtfbWFjb3N4Ljd6&_s2member_sig=1427550851-7362961786359cc658df8f779c90428e
https://www.velomap.org/support/membership/?_s2member_vars=file..level..1..file..odbl%2Fvelodenmark_macosx.7z..Lz9zMm1lbWJlcl9maWxlX2Rvd25sb2FkPW9kYmwvdmVsb2Rlbm1hcmtfbWFjb3N4Ljd6&_s2member_sig=1427550851-7362961786359cc658df8f779c90428e
302: Temporary redirect to https://www.velomap.org/support/membership/
https://www.velomap.org/support/membership/
200: HTTP/1.1 200 OKNot working with German cookie (the redirect to /de/ is not supposed to happen for a .7z file):
https://www.velomap.org/?s2member_file_download=odbl/veloestonia_macosx.7z
302: Temporary redirect to https://www.velomap.org/de/?s2member_file_download=odbl/veloestonia_macosx.7z
https://www.velomap.org/de/?s2member_file_download=odbl/veloestonia_macosx.7z
302: Temporary redirect to https://www.velomap.org/de/
https://www.velomap.org/de/
200: HTTP/1.1 200 OKhttps://www.velomap.org/?s2member_file_download=odbl/veloestonia_macosx.7z
Redirects here to
https://www.velomap.org/de/https://www.velomap.org/de/?s2member_file_download=odbl/veloestonia_macosx.7z
Redirects here to
https://www.velomap.org/de/am I missing something?
yes – I also only found this out after installing the chrome redirect extension…
and your first link only redirects to velomap.org/de/ because you still have German language cookie somewhere. If you would first surf to velomap.org/en/ then surf to
https://www.velomap.org/?s2member_file_download=odbl/veloestonia_macosx.7zyou would end up at https://www.velomap.org/support/membership/ instead.
https://www.velomap.org/en/?s2member_file_download=odbl/veloestonia_macosx.7z
would send you to http://www.velomap.org in any case as it would set language cookie to english, while the link
https://www.velomap.org/de/?s2member_file_download=odbl/veloestonia_macosx.7z
will always set German cookie then redirect you to http://www.velomap.org/de/The solution you can only see with the intermediary 302 links in the redirect chain.
The correct path would be:
https://www.velomap.org/?s2member_file_download=odbl/velodenmark_macosx.7z
302: Temporary redirect to https://www.velomap.org/support/membership/?_s2member_vars=file..level..1..file..odbl%2Fvelodenmark_macosx.7z..Lz9zMm1lbWJlcl9maWxlX2Rvd25sb2FkPW9kYmwvdmVsb2Rlbm1hcmtfbWFjb3N4Ljd6&_s2member_sig=1427550851-7362961786359cc658df8f779c90428e
https://www.velomap.org/support/membership/?_s2member_vars=file..level..1..file..odbl%2Fvelodenmark_macosx.7z..Lz9zMm1lbWJlcl9maWxlX2Rvd25sb2FkPW9kYmwvdmVsb2Rlbm1hcmtfbWFjb3N4Ljd6&_s2member_sig=1427550851-7362961786359cc658df8f779c90428e
302: Temporary redirect to https://www.velomap.org/support/membership/
https://www.velomap.org/support/membership/
200: HTTP/1.1 200 OKcleared cache and cookies, clean
https://www.velomap.org/?s2member_file_download=odbl/veloestonia_macosx.7z
Redirect to here
https://www.velomap.org/support/membership/clean approach to the site goes to the default language
yes – and that’s what should always happen, also with German cookie!!!
Right now it only happens without cookie, or with english cookie…(not that in your clean cache example you end up at the checkout page …/support/membership/ and not at the frontpage).
However with German cookie qtranslate-x interferes somewhere and redirects first to
https://www.velomap.org/de/?s2member_file_download=odbl/veloestonia_macosx.7z
and then on a second 302 to the frontpage.If I get it:
https://www.velomap.org/?s2member_file_download=odbl/veloestonia_macosx.7z
must go to
https://www.velomap.org/support/membership/https://www.velomap.org/?s2member_file_download=odbl/veloestonia_macosx.7z
in German must go to
https://www.velomap.org/de/support/membership/It is the same link – right?
- The topic ‘Disable automatic link rewriting for downloads not working’ is closed to new replies.