Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi all,
I'm sure that I'm going to ask for something easy and probably silly, but I need you help.
I have followed the steps from the readme.txt:
- module js is installed and enabled
- js.php is moved to the root directory (same than .htaccess)
- next code is added to the .htaccess
# Rewrite JavaScript callback URLs of the form 'js.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/js\/.*
RewriteRule ^(.*)$ js.php?q=$1 [L,QSA]
Now I'm watching the http requests and I really don't know if the module is working or not. I'm checking the js requests but I don't appreciate any difference.
Could you tell me how to know whether the module is working or not.
Thanks
Javier
Comments
Comment #1
michielnugter CreditAttribution: michielnugter commentedHi,
There is a very simple way of checking that the js callback works. You can debug this using a debugger or using a more basic approach:
Place the following as the first line of code in the js.php file:
echo "test"; exit;
If it doesn't echo test and exit, you're not running on js.php yet.
Comment #2
javier.drupal.2012 CreditAttribution: javier.drupal.2012 commentedHi,
I tried your code adding the line
echo "test"; exit;
to the js.php. However, my application is not showing test.Is there any way to know what is the matter to solve the problem?
If it is useful for you, when I access to the configuration of the js module in admin/config/development/performance, there is not any new field referencing the js module configuration. See a picture attached.
The status report is fine and it is not showing any error for js module.
Thanks heaps
Javier
Comment #3
javier.drupal.2012 CreditAttribution: javier.drupal.2012 commentedHi,
I don't know why but js.php is not being called at all. Anyway, If I manually call the path localhost:8082/js.php?q=url, I got a 403 for the js.php file
Any advise about this issue?
Thanks
Comment #4
michielnugter CreditAttribution: michielnugter commentedHi Javier,
Did you also try the echo "test"; die(); when calling the js.php file directly?
If you provide access arguments or an access callback it checks the those and if they fail the js.php will trigger a 403 warning. Another 403 warning can be that the module in the path cannot be found.
If it's none of these things I guess it must be your server configuration, that part I'm not that good at unfortunately.
Let me know if/when you figured out the problem.
Comment #5
michielnugter CreditAttribution: michielnugter commentedClosing this issue as there hasn't been any activity in the last month anymore. Please let me know if you need more help.
BTW, I just reread some of your comments. I seems that the js module is just not enabled or your cache is incorrect, it really should have a configuration page. Maybe if you try the latest dev version you'll have more luck.
Comment #6
javier.drupal.2012 CreditAttribution: javier.drupal.2012 commentedHi again,
I have had the chance to try again this module. I am having the same issue. However, when I write the echo "test"; exit; in the js.php file, the js/shs/json query answering test.
This makes me think that js.php is enabled and the redirection is ok.
Js files are working fine, however, the shs module query (/js/shs/json) is responding an empty fileld, therefore, the shs module is not showing the results and the js script is failing with a "TypeError: data is null" in the line
if (data.success == true) {
Could you help me with this issue?
The redirection rules that I have in the .htaccess is
# Rewrite JavaScript callback URLs of the form js.php?q=x.
RewriteCond %{REQUEST_URI} ^\/([a-z]{2}\/)?js\/.*
RewriteRule ^(.*)$ js.php?q=$1 [L,QSA]
RewriteCond %{QUERY_STRING} (^|&)q=((\/)?[a-z]{2})?(\/)?js\/.*
RewriteRule .* js.php [L]
My server is a LiteSpeed one.
If you need more info let me know.
Thanks heaps!
Javier
Comment #7
SKAUGHTinsert above drupals 'normal' RewriteCond
Comment #8
markhalliwellI know this works on the 7.x-1.x branch as well as the 7.x-2.x. Unfortunately I do not have the time to debug this. This question is more appropriate for http://drupal.stackexchange.com
Comment #9
chriscalip CreditAttribution: chriscalip commentedThis solved this for me, quote:
Hi
It seems Apache automatically calls js.php for requests like /js/*. This happens because of MultiViews option that is enabled by default. You should add this line to your .htaccess in order to disable the multiviews feature and make requests work properly:
Options -MultiViews
Regards
Comment #10
ArtuDrop CreditAttribution: ArtuDrop commented#9 is the great solution for me.
Thank you.