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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Si
    Such Fun!
    • Feb 2008
    • 13900

    #1

    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
  • Si
    Such Fun!
    • Feb 2008
    • 13900

    #2
    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.

    Comment

    • sarettah
      see you later, I'm gone
      • Oct 2002
      • 14297

      #3
      Originally posted by Si
      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.
      All cookies cleared!

      Comment

      • Si
        Such Fun!
        • Feb 2008
        • 13900

        #4
        Originally posted by sarettah
        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!

        Comment

        • sarettah
          see you later, I'm gone
          • Oct 2002
          • 14297

          #5
          Originally posted by Si
          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?
          All cookies cleared!

          Comment

          • CPimp
            Confirmed User
            • Aug 2009
            • 2346

            #6
            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.
            three 997 three 55 three 1 ← That's my ICQ. Contact me there. Thanks.

            Comment

            • Si
              Such Fun!
              • Feb 2008
              • 13900

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

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

              Comment

              • harvey
                Confirmed User
                • Jul 2001
                • 9266

                #8
                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
                This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth

                Comment

                • Si
                  Such Fun!
                  • Feb 2008
                  • 13900

                  #9
                  Originally posted by tube2k
                  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?

                  Comment

                  • sarettah
                    see you later, I'm gone
                    • Oct 2002
                    • 14297

                    #10
                    Originally posted by Si
                    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.
                    All cookies cleared!

                    Comment

                    • Si
                      Such Fun!
                      • Feb 2008
                      • 13900

                      #11
                      Originally posted by harvey
                      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.

                      Comment

                      • harvey
                        Confirmed User
                        • Jul 2001
                        • 9266

                        #12
                        Originally posted by Si
                        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>
                        Last edited by harvey; 02-14-2010, 03:37 PM.
                        This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth

                        Comment

                        • Si
                          Such Fun!
                          • Feb 2008
                          • 13900

                          #13
                          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?

                          Comment

                          • Si
                            Such Fun!
                            • Feb 2008
                            • 13900

                            #14
                            Originally posted by harvey
                            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

                            Comment

                            • harvey
                              Confirmed User
                              • Jul 2001
                              • 9266

                              #15
                              Originally posted by Si
                              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?
                              This post is endorsed by CIA, KGB, MI6, the Mafia, Illuminati, Kim Jong Il, Worldwide Ninjas Association, Klingon Empire and lolcats. Don't mess around with it, just accept it and embrace the truth

                              Comment

                              • fris
                                Too lazy to set a custom title
                                • Aug 2002
                                • 55679

                                #16
                                always use blog info
                                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                                Comment

                                Working...