Here is the article.
I have a question similar to this one:
I have created a small PHP program that I want to call as a rest web service to return some data from custom MySQL tables.
I can put it anywhere, but I've tried the root folder (public_html), a folder I creatd called custom, and the cgi-bin folder.
For the first two, I get 404 not found. For the CGI-BIN it looks like it redirects to my home page.
I've set it with CHMOD to 755 (and the custom folder as well).
My .htaccess looks like this. I think maybe it needs to change somehow?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Is there a particular reason you didn't use the WP REST API and $wpdb
calls to fetch the data? I'm not sure what WP knowledge could be helpful here, this looks like a generic hosting issue that requires Apache htaccess knowledge – Tom J Nowell♦ Nov 14, 2017 at 18:11
Move Wordpress from root folder into subdirectory and create a .htaccess
file in root folder, and put this content inside (just change example.com and my_subdir):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ my_subdir/index.php [L]
That's all :)
No comments:
Post a Comment