Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 2 of 2

This is a discussion on Modrewrite/htaccess question in the Shared & Semi-Dedicated forum
Sorry this is kinda offtopic... hopefully someone can help. RewriteEngine On RewriteRule ^articles/(.*) /articles.php?ID=$1 RewriteRule ^articles/ /articleslist.php What's wrong with that? I know the rules ...

  1. #1
    JPC Member
    Join Date
    Mar 2003
    Posts
    22

    Modrewrite/htaccess question

    Sorry this is kinda offtopic... hopefully someone can help.

    RewriteEngine On
    RewriteRule ^articles/(.*) /articles.php?ID=$1
    RewriteRule ^articles/ /articleslist.php


    What's wrong with that? I know the rules are conflicting because of them both pointing to articles/... but that may not be the problem. The articleslist.php displays the news articles in a abreviated list, where as articles.php (with its corresponding uniquely pulled id) is the individual page for that article. Any ideas? thanks guys..

  2. #2
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    The first definition is firing when you wnat the second one to. Basically, what you are saying is "match the literal string 'articles/' followed by anything." Since articleslist.php fits the definition of "anything," mod_rewrite is converting it to /articles.php?ID=articleslist.php (most likely).

    Try reversing the order for the two definitions. Also, adding a [L] to teh end of the articleslist.php rule (stands for last) so that it will stop trying to match other rules after that one. If nothing else, it will help speed up your page loads a bit. You'll probably also need an [QSA, L] at the end of the artiles.php rule. QSA stands for Query String Append and tells mod_rewrite to look for and parse a querystring on the rewritten URL.

    Here's what you should have when you're done:
    Code:
    RewriteEngine On
    RewriteRule ^articles/ /articleslist.php [L]
    RewriteRule ^articles/(.*) /articles.php?ID=$1 [QSA, L]
    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •