Access Standalone PHP File With Wordpress Installed - php

I have just installed wordpress on a site. However, I have some standalone php files that I use for analyzing database data on the site that now return a 404 when trying to access them.
For example:
www.mywordpresssite.com/myscripts/myscript.php
This returns a 404.
Here is my .htaccess:
# 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>
Is there any way I can achieve normal access to the said directory/file but without upsetting the current functionality of Wordpress?
Thanks a lot

Change your .htaccess file to this
# 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>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/myscripts/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>

Related

Why are all my wordpress pages redirecting to home?

I have a page call inventaires, the permalink is mywebsite.com/inventaires
Whenever I try to reach it I am redirected to the homepage mywebsite.com
My htc access is as follow :
# 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
Does somebody know what's wrong ?
My solution :
Clear cache of the browser. It was using a wrong cached version. :(
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
# END WordPress
try this code

WordPress Htaccess breaking rest of site

To start, I am hosting my website on AWS. I have a normal WordPress site in the root, with a custom application in a sub-folder. The Htaccess in the sub-folder is:
//Htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
And the Htaccess in the root:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I have a feeling WordPress is screwing up my application in /sub/, cause it was working before I moved Wordpress to the root. If you need additional info, let me know. How do I get Wordpress to ignore that directory?
You need to add default htaccess for root directory of wordpress site.
Read out the documentation here for basic , subdomains , multisite etc.
# 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>
Place this htaccess in sub folder.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

exclude folder in wordpress using htaccess failed

I created a folder named folder1 after entering the root. At that level of directory there's my .htaccess, I googled and I paste the following line at
..
RewriteRule ^index\.php$ - [L]
// this
RewriteCond %{REQUEST_URI} !(folder1|folder2|folder3) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
..
But when I go to mydomain.com/folder1, it returned 404 of my wordpress?
You should post all of your code so that we can make sure there aren't other rules conflicting. Not just the part you can't get working.
Try using THE_REQUEST and try it this way and put it above your wordpress rules. So if it matches then do nothing.
RewriteCond %{THE_REQUEST} ^(GET|POST) /(folder1|folder2|folder3) [NC]
RewriteRule ^ - [L]
I found this, exclude subfolder with wordpress .htaccess and workds for me.
I put this before WordPress rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/yoursubdirectoryname1/(.*)$
RewriteRule ^.*$ - [L]
</IfModule>
and here is WordPress rules:
# 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
My complete .htaccess code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/yoursubdirectoryname1/(.*)$
RewriteRule ^.*$ - [L]
</IfModule>
# 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
source: I found this code on WordPress forum.

htaccess issue with multiple wordpress installed in root and subdirectory

I have installed 2 wordpress site in one host. Originally I have installed it in root folder, for some reason I need to install another wordpress site separately in a subfolder which later on I will going to link it in a subdomain. While I have sucessfully Installed the new wordpress, however I have an issue with my htacccess.
Here is my htaccess in my root
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
# 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
and here is my htaccess in the subfolder
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /help
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /help/index.php [L]
</IfModule>
# END WordPress
Change
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /help
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /help/index.php [L]
</IfModule>
# END WordPress
To
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /help
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

How do I remove the extension for an external file in my wordpress htaccess file?

At the moment I have the following in my wordpress .htaccess file:
# 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
I've uploaded a separate .php file called contact.php that I'd like to rewrite so that users can access it via http://mydomain.com/contact instead of http://mydomain.com/contact.php
What do I need to put into my .htaccess file so that I can have this rewrite for this one file only?
Just add one line for your redirect as shown below:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^contact$ /contact.php [L] <-- New Line
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
You should put this before the # BEGIN WordPress comment, since it's not WP related:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^contact$ /contact.php [L] # /contact rewrite
</IfModule>
# 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

Categories