How do I run separate PHP script in directory of Wordpress?

8 replies
I'm trying to run a twitter script in a subdirectory of a site that has wordpress installed on it. I can't get it to work because the index.php file inside the directory keeps get rewritten to show the wordpress site (root of the domain).

What do I put in the htaccess file inside the subdirectory to make it show the new index.php file and not the main site?
#directory #php #run #script #separate #wordpress
  • Profile picture of the author John Rogers
    I'm not sure, as I haven't used it, but the runphp plugin might do the trick.

    no sq – runPHP Plugin for WordPress

    John
    {{ DiscussionBoard.errors[1685518].message }}
    • Profile picture of the author xlfutur1
      Originally Posted by John Rogers View Post

      I'm not sure, as I haven't used it, but the runphp plugin might do the trick.

      no sq - runPHP Plugin for WordPress

      John
      I believe this plugin simply allows for php code to work inside regular posts. I need an index.php file to work in a subdirectory without being affected by the main htaccess in wordpress.
      {{ DiscussionBoard.errors[1685621].message }}
  • Profile picture of the author JohnMcCabe
    When you say "the index.php file inside the directory keeps get rewritten to show the wordpress site", do you mean the actual source code on the server gets overwritten? Or do you mean that when you try to access the subdirectory, you get redirected to the blog's home page?

    If it's the first, I can't help you.

    If it's the second, you likely need to tweak the htaccess for the root directory to exclude your subdirectory. You'll need a better coder than me to get it right, though...
    {{ DiscussionBoard.errors[1685878].message }}
    • Profile picture of the author xlfutur1
      Originally Posted by JohnMcCabe View Post

      When you say "the index.php file inside the directory keeps get rewritten to show the wordpress site", do you mean the actual source code on the server gets overwritten? Or do you mean that when you try to access the subdirectory, you get redirected to the blog's home page?

      If it's the first, I can't help you.

      If it's the second, you likely need to tweak the htaccess for the root directory to exclude your subdirectory. You'll need a better coder than me to get it right, though...
      I get what looks like a post basically, so its the 2nd one. I do think its just a htaccess file solution, but I don't know what code to put in that file to make it exclude that directory. I emailed the author of the script, so hopefully I will hear back from him. Otherwise I will just use a domain that doesn't have wordpress installed on it.
      {{ DiscussionBoard.errors[1686014].message }}
  • Profile picture of the author getsmartt
    I think John is on the right path...over my head on the proper code though...you might try the programming forum or the wordpress forum over at wordpress.org they are quite smart and generally helpful over there
    Signature

    Was mich nicht umbringt, macht mich stärker

    {{ DiscussionBoard.errors[1685893].message }}
  • Profile picture of the author Andrew E.
    Is your twitter script named index.php? Why not rename it if it is, that way it does not overwrite your wordpress front page?

    You would still be able to access it via the new name.
    {{ DiscussionBoard.errors[1685899].message }}
  • Profile picture of the author istok
    That should not be a problem. I have plenty of subdirectories in my WP root, all containing index.php in it, and they all work fine.
    {{ DiscussionBoard.errors[1686774].message }}
    • Profile picture of the author webmasteruk
      This may be a daft answer as I did not really understand your question. But I hope this will maybe give you some ideas to a solution.

      You could use a plugin like John suggested or there are a few more that will allow you to execute php code on a wordpress page. A gogle (what is gogle I meant google!) will give you good results.

      Then why dont you just use the PHP include comand and have it pointing to the index.php in the folder in question?

      That should work.

      Again I did not really understand your question so I was clutching at straws hoping that this will help you out.
      {{ DiscussionBoard.errors[1686891].message }}

Trending Topics