• I’ve spent hours trying to figure this problem out, but I think it should be simple for some…

    My blog is at toshuo.com/index.php. What I’m trying to do is to set up a rewrite rule so that people can access my blog at “toshuo.com/index”. I do NOT want to move my whole blog structure under /index/. I just want to make it so that people can go to “/index” rather than “/index.php”. Here’s my .htaccess file:

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

    The only line I added was <b>RewriteRule ^index index.php [PT]</b>. It seems like it should work, but going to https://toshuo.com/index yields a WP 404 error. Any ideas?

    PS. I don’t mean to beat a dead horse, but I do NOT want to move all my blog posts, categories and archives under a subdirectory!

    PPS. The root, i.e., https://toshuo.com/ is a simple HTML file. I don’t want to move it, either.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Well, having an index.html AND an index.php in the same directory… that’s not a wise idea.

    try
    RewriteRule ^index /index.php
    and
    RewriteRule ^index$ /index.php

    Thread Starter xiaoma

    (@xiaoma)

    Replacing the rule I added with those two resulted in a 500 Internal Server Error on every page of my blog. any other ideas?

    Thread Starter xiaoma

    (@xiaoma)

    Moshu, if you can think of another way to get similar functionality, I’m all ears.

    I’ve spent hours online searching for a way to have a static home page, keep a way for visitors to access an index of my most recent entries, and NOT put my entire blog under a subdirectory as many others have done. I’d love it if there were some simple way to make a page in wordpress that loads my blog entries (without wiping out my home page). If that were possible, I’d make a page that loaded my most recent 10 entries, name the page “index” and be done with it.

    I just thought that using mod_rewrite would be easier!

    Regardless if it’s a blog or something else – normally you can not have 2 index files in the same directory.
    If you think you can… I am clueless.

    Well, I’ve got a client who has an index.html file in the same folder as a root install of wp. It loads ahead of wp’s index.php just fine, and the root install of wp is also using home.php. All works okay on his site….

    Maybe because of the home.php?
    I remember once (during testing) I installed WP in the root and the index.html was still there… and a lot of functions didn’t want to work: as they were looking for the “default” index file of the directory!

    vkaryl – does that client then have index.php in his permalinks (aka “almost pretty”)?

    Huh. Well, this site’s working fine (it better – it’s a pretty good sized corp. site!) – maybe it is because of the home.php setup. Hard to say, it was set up like that when he came to me for tweaks….

    I’ve never myself had one I wanted to have an .html splash page in….

    [Oh, and btw, I NEVER consider anything to do with .htaccess “simple”.]

    Thread Starter xiaoma

    (@xiaoma)

    When there’s a request for /, Apache checks index.html before index.php. As I said before, I’m more than willing to abandon this method and have a static page at index.php, but I don’t know how to get at an index of my blog posts if I do that.

    Does anybody know how to display all the recent entries from a different php file? (home.php doesn’t work because if it’s there, WP ignores index.php) I’ve tried copying the contents of my index.php into “blog.php”, but it breaks when I try to load blog.

    > When there’s a request for /, Apache checks index.html before index.php

    Maybe by default, but it doesn’t have to be that way. These things *can* be controlled.

    To display all the recent entries *in* a different php file, just put The Loop in that file. Not sure why you’d want to do that, though; if what you want is to have a list of your recent entries on the home page, you could modify the stuff in TheLoop to not show the entire post (e.g., just the title, or the title and a snippet).

    Thread Starter xiaoma

    (@xiaoma)

    What I want is a list of recent entries, but NOT on the homepage. As I said above, my homepage is static. I want to display recent entries on some other page. For the purpose of this conversation let’s just say I want a page called “recent” that acts just like toshuo.com/index.php does now.

    Thread Starter xiaoma

    (@xiaoma)

    I just created a php file called “index2.php” in my theme directory, and it’s identical to my “index.php”, except that I’ve added
    <?php
    /* Template Name: index2 */
    ?>

    to the top of it. It includes The Loop. Then I made a page called “test”, and selected index2 as the page template for it. Unfortunately, instead of loading up my ten most recent entries as index.php does, it doesn’t display any at all. You can see the results on https://toshuo.com/test.

    Is there some step I missed?

    Thread Starter xiaoma

    (@xiaoma)

    I got it! The answer was here! I just had to add

    <?php query_posts('showposts=10'); ?><?php $more = 0; ?>

    before The Loop. Yay! Thanks for getting me on the right track, everyone! Case closed!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘A simple .htaccess problem’ is closed to new replies.