0

I have Wordpress installed in the root directory and configured properly using permalinks.

Alongside the Wordpress blog, I have a full-fledged custom developed php application with several pages. I want to not show the .php extension for any of the custom pages, but I'm now getting 404 errors for all the custom php pages.

http://url/blog-title-here (word press page - works)

http://url/register (custom php page - results in 404)

Here's what my .htaccess looks like:

# 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>

And here's what I have in httpd.conf

<Directory />
Options FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
</Directory>
  • It's a question about Apache, not WordPress. – Max Yudin Jul 8 '16 at 18:02
  • this is a bad idea which will have surprising results when your authors create new page. keep the .php suffix or move your app to a subdirectory so at least there will be only one "illegal" slug. – Mark Kaplun Jul 9 '16 at 9:52
0

(EDIT) Take the custom rules outside the # Begin Wordpress (credit to Tim Malone)

You can check if the file exists in the root and load it before the Wordpress rules kick in:

# check for a file, i.e register.php
# load it if found and stop processing the rest of the rules with the [L] flag
<IfModule mod_rewrite.c> 
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteCond %{REQUEST_URI} !/$1.php
RewriteRule ^(.*)  /$1.php [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

http://url/register will then open the register.php file in the root.

If the file is not found, the Wordpress rules are processed.

  • Actually register.php is in the root directory, alongside .htaccess, and all the other wordpress files. – timw07 Jul 8 '16 at 21:14
  • I'd probably put the custom rules outside of #BEGIN WordPress, not 100% sure but WordPress might override them if the rewrite rules are hard flushed (as they are when clicking Save on Settings -> Permalinks). – Tim Malone Jul 8 '16 at 22:10
  • Tim is probably right, edited the answer! – P-S Jul 9 '16 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.