• Resolved ebeighe

    (@ebeighe)


    If i put a file into my blog’s root called abc.html
    I can access it as expected.

    However, if i put a file called abc.php
    I cannot access it, and instead get redirected to my blog’s generic file not found page.

    How does that work?

    In a somewhat related question:
    I used to have my blog in the subfolder blog, and have permalinks with post name. I recently moved everything up to the root of my domain… so an example link might be
    mydomain.com/a-post-name
    It’s pretty clever, but I’m wondering why does the old link still work?
    mydomain.com/blog/a-post-name

Viewing 3 replies - 1 through 3 (of 3 total)
  • WordPress, on Apache servers, generates an .htaccess file that basically tells Apache to capture all requests for php files and direct them to WordPress to act on. So if that PHP file is actually not a part of WordPress, WordPress will try and execute it and fail as it’s not following WordPress’ API. To work around this, you can either put WordPress (and its .htaccess file) in its own subdirectory so that your custom PHP files aren’t in the same directory as WordPress. Or you can create a custom rewrite via the .htaccess file to basically tell the server to not go to WordPress to act on that particular file.

    As to your 2nd related question, this is, again, likely due to the .htaccess file (normally invisible – use an FTP program or set your control panel options to see invisible files to view). And WordPress is smart enough that if a request name is close enough to an existing post, it will show that post.

    Thread Starter ebeighe

    (@ebeighe)

    ah, of course, the .htaccess file is involved with permalinks. I knew that (but forgot)! Thanks.

    Thread Starter ebeighe

    (@ebeighe)

    marked resolved

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘redirection’ is closed to new replies.