简体   繁体   中英

wordpress plugin js file 403

Trouble accessing JS file from plugin: Current implementation (implementing parsley.js library) Background: windows 10 - xampp 1.8.2 - apache 2.4, php 5.6

wp_enqueue_script( 'parsley_script', plugin_dir_url( __FILE__ ).'js/parsley.min.js');

The file present and receives 403

Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server.

Error log shows

[access_compat:error] [pid 4024:tid 2456] [client 127.0.0.1:62015] AH01797: client denied by server configuration:

Server configuration

<Directory "D:/www/htdocs/wordpress">
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
</Directory>

.htaccess

# BEGIN s2Member GZIP exclusions
<IfModule rewrite_module>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{QUERY_STRING} (^|\?|&)s2member_file_download\=.+ [OR]
    RewriteCond %{QUERY_STRING} (^|\?|&)no-gzip\=1
    RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END s2Member GZIP exclusions

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

This similar question is not valid on a window box (permissions) wordpress - Error 403 file javascript plugin wordpress

Please help. I can add this same file to a theme/ directory and don't get the 403 error. It can be bypassed but the reason behind something so trivial is bugging me beyond belief. Also, I would like to isolate the script to the plugin as it should not be dependent on the theme (since the plugin creates the form required as a short code)

The simplest of things... For the plugin I had a .htaccess file there which limited apache to serve png|gif files only... /plugin_dir/plugin_name/.htaccess

<FilesMatch "^(.+)\.(png|gif)$">
Allow from all
</FilesMatch>

This was adjusted to

<FilesMatch "^(.+)\.(png|gif|js|css)$">
Allow from all
</FilesMatch>

Such a simple thing which I missed while searching. NOTE TO SELF (AND OTHERS) - don't look for the most complicated answer first

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM