Ready to get started?Download WordPress


404 and Modrewrite (7 posts)

  1. wizzard81
    Posted 7 years ago #


    I've made a little linkexchange script myself and the url currently is something like =>


    But when i work via the modrewrite like


    This =>

    RewriteRule ^resource-directory/(.*)/(.*)\.(.*) http://www.health-weightloss-information.com/index.php?page_id=14&category=$1&subcategory=$2 [L]
    RewriteRule ^resource-directory/(.*)\.(.*) http://www.health-weightloss-information.com/index.php?page_id=14&category=$1 [L]

    Well nothing seems to work what i try because wordpress gives me always an 404 error that the page not could be found.

    Can anyone in here help me please?

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Actually, your rewrite seems to be working fine to me. Of course, it's doing a redirect, but still...

  3. wizzard81
    Posted 7 years ago #

    Well i always receive an error 404 from wordpress.

    I have installed the phpexec plugin so i have include in the page/resource-directory/ the real page

    => <phpcode><?php include("links.php"); ?></phpcode>

    This needs the $category and/or $subcategory

    This works => RewriteRule ^resource-directory/(.*)\.(.*) http://www.health-weightloss-information.com/index.php?page_id=14&category=$1 [R=301,L]

    But this is not working => RewriteRule ^resource-directory/(.*)\.(.*) http://www.health-weightloss-information.com/index.php?page_id=14&category=$1 [L]

    When i remove the R=301.

    I know its something in the permalink functions of wordpress.

  4. wizzard81
    Posted 7 years ago #

    So no one can help me ?

  5. jrawle
    Posted 7 years ago #

    It only works as a redirect because you are using the full URL including the domain name. Rewrites are usually to a file on the same server, so you should just use /index.php?page...

    Also, did you add something to WordPress's index.php? Why not move your script to a different PHP file?

    I have seen WordPress return a 404 header when the WP header is used with custom scripts. You can fix this by putting
    header('HTTP/1.1 200 OK');
    at the start of your script (it needs to be before anything is output, otherwise a header will be sent automatically).

  6. wizzard81
    Posted 7 years ago #

    If i put my script in a different php file how can i use the theme in my php file ?

    For the rewrite i used also /index.php

  7. jrawle
    Posted 7 years ago #

    To use the WordPress theme, simply add add the top:

    define('WP_USE_THEMES', false);

    And at the end:

    get_sidebar(); get_footer();

    Are you still having rewrite problems or not?

Topic Closed

This topic has been closed to new replies.

About this Topic