2

I am trying to convert some data from custom post types into custom tables in my Wordpress database. I have written a PHP program to do this. It requires that Wordpress be loaded so I can use some of Wordpress's database access methods ($wpdb). I have placed the conversion file in my site's root directory where index.php resides, but when I try and run it

http://my-site.dev/convert.php/

I get a 404 page not found error. How can I configure Wordpress or my server (I'm using Desktop Server locally for development) to run this program?

4
  • 1
    Sorry. The file is not in wp-contents but rather the site's root directory. Commented Jul 26, 2017 at 19:20
  • Have you looked at WP CLI? PHP files shouldn't have slashes on the end like that, its trying to load a folder named convert.php, but that's not how URLs work
    – Tom J Nowell
    Commented Jul 26, 2017 at 19:47
  • @RussellEubanks please edit your question/title with that information.
    – MrWhite
    Commented Jul 26, 2017 at 19:52
  • @TomJNowell On most Apache servers, this would actually be a perfectly valid request. The trailing slash (on an existing PHP file) is simply seen as additional pathname information (PATH_INFO) and convert.php would be loaded just fine (providing it exists). However, if AcceptPathInfo Off is set in the server config (or .htaccess file) then this will indeed trigger a 404 - but this is not the default behaviour for PHP handlers. But maybe this is what's happening here? (/convert.html/ on the other hand would trigger a 404 by default because the core handler rejects path info.)
    – MrWhite
    Commented Jul 26, 2017 at 21:20

1 Answer 1

1

Installing a plugin had modified my .htaccess file. When I restored to the saved original, I was able to run PHP scripts just fine. Thanks to Denver Wordpress Meetup group for suggestions.

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.