WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Page templates redirecting to index.php? (6 posts)

  1. jacobw
    Member
    Posted 8 years ago #

    Really mysterious. I'm developing a WP 2.0.1 blog (on my local machine - can't give a link, sorry). I've created some custom page templates and based some pages on them, but instead of loading those pages when I click on the link that automatically appears in my sidebar, WP loads index.php instead. Anyone have any thoughts why this might be happening? I've been trying to find information in the codex about what point WP decides which page template is going to load when requesting a page, and I found a page that says it goes in the order of custom-page-template.php, page.php, index.php, but nothing about why it might ignore my custom-page-template.php and page.php and load index.php instead. I know it's loading index.php because I put die('loaded index.php'); at the top of my index.php page and that's what displayed when I clicked on the link to the page in the page list in my sidebar.

    Alternatively, does anyone know where in the WP code it decides which template it should load, so I can check some variables to find out what isn't being set properly?

  2. jacobw
    Member
    Posted 8 years ago #

    Okay, after having played with this for a few more minutes I've realized that it's because of a .htaccess problem.

    For some reason, it doesn't matter what option I pick i Options > Permalink, the only thing clicking on 'Update Permalink Structure' does is add a blank line to the bottom of my .htaccess file.

    So, if I start out with a .htaccess file looking like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    ...which is how it currently looks, and I change the permalink option to eg the 'Date and name-based' opiton, then click on 'Update Permalink Structure', the .htaccess looks exactly the same, but with a blank line added to the end.

    I've tried all the suggestions in 'Fixing Permalink Problems' on Using Permalinks but nothing has helped.

    Has permalink generation itself been broken in WP 2.0.1? I would have thought I'd have heard more about it in here if it had...

    Anyone have any suggestions?

  3. jacobw
    Member
    Posted 8 years ago #

    Okay, please ignore. After much, much messing around, you know turned out to be the problem? For some reason I was missing the auto_increment property on the option_id field in wp_options. I guess the rewrite rules are stored in there, and it couldn't write them because auto_increment wasn't enabled.

  4. PavloP
    Member
    Posted 8 years ago #

    hi,

    I have the same problem. Whatever I do .htaccess code is generated always the same. I see it at Options > Permalink page.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    I have WordPress 2.0.1, mod_rewrite is working because it works with single posts. index.php and .htaccess reside in the root directory and wordpress is intalled into the /wordpress/ directory. wp_opitions table contains auto_increment on option_id field.

    I have many static pages but have to rules generated for them.

    Does anyone know how to solve this problem?

  5. Chris_K
    Member
    Posted 8 years ago #

    PavloP - what exactly IS the problem you're having? Have a link you could share to illustrate?

    WP 2.x doesn't write much out to .htaccess anymore. Most of it is handled internally, so don't be too alarmed not to see much in .htaccess.

  6. moshu
    Member
    Posted 8 years ago #

    One problem might be that the .htaccess file has to be in the WP directory.
    Otherwise, since WP 2.x the .htaccess rules are exactly as you posted above - the rest is done internally.

Topic Closed

This topic has been closed to new replies.

About this Topic