0
votes

i have wordpress on the root of the server. .htaccess is below.
I would like to place a PHP file - say RR.PHP- or even a folder - say RR_FOLDER - holding PHP files at the server's root.
I do not manage to get along with specifying the correct Rewrite rule to achieve that.
Trying the following yields various errors: 404, 501 302

  • RewriteRule ^rr.php$
  • RewriteRule ^rr.php$ {full_path}/rr.php

I also appended [R] flag which did not help.
What did I miss?

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive Off
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##


# 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
2
If you have php files sitting in your root, the !-f check will fail and wordpress will ignore them, you don't need any special rules. - Jon Lin

2 Answers

1
votes

You can try these rules:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^(rr\.php)$ full_path/$1 [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

That is your rewrite rule should come before WP standard rules.

0
votes

As Jon Lin said, special rules are not needed.
The file permissions and the file owner should be appropriate to the user own the server.

You can copy the permissions from wp-content.php(or other running/working php file) to other file with:
chmod -R --reference=wp-admin yourFiles
In addition make sure the right user is own the file.
If not change owner with:
chown <userName> yourFiles