GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Scripting / wp / .htaccess kinda question [help!] (https://gfy.com/showthread.php?t=953767)

Si 02-14-2010 04:34 PM

Scripting / wp / .htaccess kinda question [help!]
 
Hey all.

I've never had this problem before, but I'm sure it's something simple.

Right so first things first. I'm trying to include a piece of java script into wordpress.

Code:

    <script type="text/javascript" src="http://domain.com/wp-content/plugins/pluginfolder"></script>
But, it appears because I have permlinks set on ( /&postname%/ ) That it will not load up what I want it to.

What is the way round this?

I'm guessing it's something simple but never had to do it before.

Thanks for any suggestions :thumbsup

Si 02-14-2010 04:36 PM

So basically all I get when trying to access the script, is a 404 error because it is trying to find a post or page.

sarettah 02-14-2010 04:47 PM

Quote:

Originally Posted by Si (Post 16849935)
So basically all I get when trying to access the script, is a 404 error because it is trying to find a post or page.

If what you have in there is domain.com/wp-content/plugins/pluginfolder then it looks like you are trying to open a folder, not a file, unless the name of the file that has your script in it is actually pluginfolder without any extension.

Usually your source comes from a file:

domain.com/wp-content/plugins/pluginfolder/myjavascript.js

Or some such.

Si 02-14-2010 04:58 PM

Quote:

Originally Posted by sarettah (Post 16849962)
If what you have in there is domain.com/wp-content/plugins/pluginfolder then it looks like you are trying to open a folder, not a file, unless the name of the file that has your script in it is actually pluginfolder without any extension.

Usually your source comes from a file:

domain.com/wp-content/plugins/pluginfolder/myjavascript.js

Or some such.

I thought it would have loaded fine aswell but it's not working which is weird!

sarettah 02-14-2010 05:23 PM

Quote:

Originally Posted by Si (Post 16849974)
I thought it would have loaded fine aswell but it's not working which is weird!

so domain.com/wp-content/plugins/pluginfolder is the name of a file? Not a folder?

CPimp 02-14-2010 05:24 PM

yeah if you're trying to include a javascript, you'd have to include the actual file, not folder. Hit me and I can help real quick before I leave.

Si 02-14-2010 05:25 PM

So is there not a rewrite rule, or exclude I do to stop it?

Or give an exception to a certain page etc... ?

harvey 02-14-2010 05:27 PM

double check your path and be sure to include the filename, this has nothing to do with .htaccess or permalinks, as long as your absolute URI path is correct, you shouldn't get a 404. I'd understand some javascript not working because it's the wrong order (ie you need to call jquery or any other library first and then the script), but it shouldn't give you a 404, so chances are you have the wrong path

Si 02-14-2010 05:28 PM

Quote:

Originally Posted by tube2k (Post 16850015)
yeah if you're trying to include a javascript, you'd have to include the actual file, not folder. Hit me and I can help real quick before I leave.

It's ok I have got it working by putting it onto a subdomain.

I was doing the file (made a mistake above) e.g.: /path/folder/file.js

Would be nice to know a rule for .htaccess to stop it from rewriting a path though if anybody knows how to do it?

sarettah 02-14-2010 05:32 PM

Quote:

Originally Posted by Si (Post 16850024)
It's ok I have got it working by putting it onto a subdomain.

I was doing the file (made a mistake above) e.g.: /path/folder/file.js

Would be nice to know a rule for .htaccess to stop it from rewriting a path though if anybody knows how to do it?

Where was it rewriting a path? If you call a folder using http:// then apache will look for index.html, index.htm, default.html, index.php (whichever flavor your settings indicate) in the folder you pointed to.

Since it looks from here like you were calling a folder then my guess is apache did not find the folder or if the folder existed it did not find a default page so then it went 404.

Si 02-14-2010 05:33 PM

Quote:

Originally Posted by harvey (Post 16850021)
double check your path and be sure to include the filename, this has nothing to do with .htaccess or permalinks, as long as your absolute URI path is correct, you shouldn't get a 404. I'd understand some javascript not working because it's the wrong order (ie you need to call jquery or any other library first and then the script), but it shouldn't give you a 404, so chances are you have the wrong path

Yeah, thats what I done. It don't make sense giving out a 404. I done both ways aswell.

http://domain.com/wp-includes/plugin...folder/file.js

and

/wp-include/filefolder/file.js

And neither of them worked. So I put the file onto a subdomain and it's now working.

harvey 02-14-2010 05:34 PM

Quote:

Originally Posted by Si (Post 16850024)
It's ok I have got it working by putting it onto a subdomain.

I was doing the file (made a mistake above) e.g.: /path/folder/file.js

Would be nice to know a rule for .htaccess to stop it from rewriting a path though if anybody knows how to do it?

again, it has nothing to do with wordpress nor htaccess, it was something you did.

If you used /path/folder/file.js you'll ALWAYS get a 404. You need to use php bloginfo('template_directory') to locate the file, like the example below:

Code:

<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/scripts/my_js_file.js"></script>

Si 02-14-2010 05:41 PM

Ok before I confuse you all let me start again and try and be more clear :)

I used the following code:

Code:

    <script type="text/javascript" src="http://domain.com/wp-includes/plugins/filefolder/file.js"></script>
So it should have been calling the file directly.

But it wasn't working, so I type in the full path as above, and it went to a 404 error page. "SORRY, WHAT YOU ARE LOOKING FOR ISN'T THERE"

So I then tried using the following code:

Code:

    <script type="text/javascript" src="/wp-includes/plugins/folder/file.js"></script>
And still nothing.

Now I have put it onto scripts.domain.com and put the files into the root and used this code

Code:

    <script type="text/javascript" src="http://scripts.domain.com/file.js"></script>
And it works!

But if it was giving out a 404 error for the path, wordpress and/or my .htaccess must have been re-writing the path right?

Si 02-14-2010 05:44 PM

Quote:

Originally Posted by harvey (Post 16850035)
again, it has nothing to do with wordpress nor htaccess, it was something you did.

If you used /path/folder/file.js you'll ALWAYS get a 404. You need to use php bloginfo('template_directory') to locate the file, like the example below:

Code:

<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/scripts/my_js_file.js"></script>

Got ya! thats why it wasn't calling it up properly. I will give that a shot and see what happens :)

harvey 02-14-2010 05:51 PM

Quote:

Originally Posted by Si (Post 16850051)
Got ya! thats why it wasn't calling it up properly. I will give that a shot and see what happens :)

btw, are you sure your absolute path isn't wp-content instead of wp-includes?

fris 02-14-2010 06:31 PM

always use blog info


All times are GMT -7. The time now is 10:38 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123