.htaccess Problem - Page 2
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: .htaccess Problem

  1. #16
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,851
    You are not clear. What, exactly, did you try? Look again at my descriptions of what the rules do and you should see that the last RewriteRule is not applied to any actual directories or actual files. If you have having a problem, pleae be more specific about what your files contain and what problem you are having.
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  2. #17
    Senior Member
    Join Date
    Apr 2003
    Posts
    167
    My apologies... I meant I tried the suggestion from your previous post. So my code looks like:

    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteRule ^directory/alabama/$ /index.php?p=21
    RewriteCond &#37;{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    Do you think the last rule is affecting the outcome of this?

    Thanks...

  3. #18
    Senior Member
    Join Date
    Apr 2003
    Posts
    167
    And just to clarify, the page redirects fine but the new URL is shown...

  4. #19
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,851
    OK we've seen your file, now we need to know what is wrong. *Please* review my explanations of what each line does above.

    It works like this
    REQUEST FOR directory/alabama comes in

    The first rule that applies is your new rule:
    Code:
    RewriteRule ^directory/alabama/$ /index.php?p=21
    NOTE: because you have both ^ and $ bracking your url in there, it has to match EXACTLY. If the user doesn't provide the trailing slash, it won't match. if they try /xyz/directory/alabama/ it won't apply. they have to ask exactly for http://example.com/directory/alabama/ (with trailing slash). You might want to try leaving off that $ char.

    IF your rule is applied because the user has asked for directory/alabama/ and not a character more or a character less then your rule is applied, which takes whatever they asked for and replaces it with /index.php?p=21.

    NOW -- and this is important to realize -- that evaluation does not stop at this point because your directive is not followed by an [L] flag. Evaluation continues to the next line. And, forgive me, but I'm not sure if &#37;{REQUEST_FILENAME} is changed by your rule being applied. You might try putting the [L] after your rule.
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  5. #20
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,851
    I've tested this on my local dev machine.

    A request for http://localhost/directory/alabama/ is redirected internally to index.php?p=21 and yet the browser shows http://localhost/directory/alabama/.

    That sounds like what you want.

    Note that going to http://localhost/directory/alabama is also referred to index.php but without the query string "?p=21".
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  6. #21
    Senior Member
    Join Date
    Apr 2003
    Posts
    167
    Thanks for your response. It looks as though the issue is with the wordpress files - index.php is loading but then redirecting. So I need to delve through those and see why that is happening.

    On that basis, the .htaccess code is correct and will work once the other files are sorted. So, thanks for all of your help through this!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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