3

I have installed wordpress blog in my domain(Ex: http://mywordpresswebsite.com). Now i have a php file called serve.php in the root like http://mywordpresswebsite.com/serve.php.

Now if i open the url in browser its saying page not found.

then i have added RewriteRule ^serve.php$ serve.php [L] in htaccess code, still its saying page not found.

Please give me a solution for this as soon as possible, thanks in advance.

0

2 Answers 2

9

Wordpress templates are located in wp-content/themes/yourthemename/. Easy way to load a custom php file is to put serve.php in that folder and to make that file a page template by putting comment below at the beginning of the file:

<?php
/*
Template Name: Serve
*/

Now go to admin->pages, create a new page and assign that page template from the template dropdown. Open the http://mywordpresswebsite.com/serve/ url in browser ( click on Show Page in admin bar ) and serve.php will be loaded.

Sign up to request clarification or add additional context in comments.

Comments

4

Actually, if it is just plain php code that you want to run, you can simply upload the file to some accessible location on your website and specify the web path to run it.

For example, upload serve.php to your theme directory and visit:

http://mywordpresswebsite.com/wp-content/themes/<theme_name_here>/serve.php

Of course, you need to replace <theme_name_here> with the name of the theme folder.

However, if your code in serve.php is not just plain PHP, but needs to interact with Wordpress objects, the execution will produce an error. PHP does not know anything about Wordpress. To see the error, you may want to temporary enable debugging output for your site by finding the .htaccess file in its root directory and appending to it :

 php_flag display_errors on

So, in case you do need to interact with your Wordpress site, you need the hack, described by Danijel

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.