i just want to add a php file into my site say www.mysite.com/some.php. I dont want to create any page using that php file as page template. All i want is to add a php file which as some php codes in it and redirects to my another page after successful access. I know it is possible and seen in many sites that they use it. How should I to do this???? any solution or at least an hint will help me.

  • 2
    There is nothing in a default WordPress install that would prevent you from placing a php file within your public html directory and accessing it directly.
    – Milo
    Commented Jan 23, 2012 at 18:41
  • @Milo But i saw some sites that they have .php files in their link with in the public html. They too use wordpress. If i cant, is there any way around to make it??
    – Felix
    Commented Jan 23, 2012 at 18:46
  • 2
    @Milo you should post that comment as an answer. In the current phrasing of the question, your comment answers it. Commented Jan 23, 2012 at 20:53
  • @ChipBennett so it is not possible to make a .php link???
    – Felix
    Commented Jan 23, 2012 at 21:02

2 Answers 2


I think you're just looking for a basic php include:

include '/some.php';

Just make sure the path is correct. I've used this before no problem, php will interpret your included file as if it were part of the file including it.

... after reading your question again you may be asking for something even simpler, just link to your file from another page to access any resource, including php files, on your site.

  • Where should i use thad code include '/some.php'; ???
    – Felix
    Commented Jan 23, 2012 at 18:48
  • You would put that into one of your theme files (or your post if you're using a plugin that lets you use php in posts). Maybe I'm not fully understanding what you are asking.
    – Jeff
    Commented Jan 23, 2012 at 19:44
  • I guess yu got my question wrongly. What i asked was how to create a separate php file and to let the user access it (say www.example.com/download.php). by using this i can execute the php code when and only my user needs to download and by passing values via url (say www.example.com/download.php?file=jpg) I can customize the code and get different results. Is that clear??
    – Felix
    Commented Jan 23, 2012 at 19:59
  • Yeah, that's clearer. Cant you just make a regular link to www.example.com/download.php?file=jpg somewhere on your page? As far as I know wordpress will serve up files that exist on your domain before doing it's own url interpretation. That's what the lines RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d mean that wordpress puts into the htaccess file when you set up permalinks. you do have permalinks set up right? Does that work for you?
    – Jeff
    Commented Jan 23, 2012 at 20:24
  • I cant link it straightly. If i try to link my www.example.com/download.php , i am end up with 404 no page found error. and i cant follow what u are tryna say with that code. Should I add that code in any part of my theme file???
    – Felix
    Commented Jan 23, 2012 at 20:38

if that file is in your theme folder then :


or if its in wordpress folder root :


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.