Forum Moderators: phranque

Message Too Old, No Replies

htaccess rewrite fails on new server

         

kenfused

2:17 am on Jul 6, 2005 (gmt 0)

10+ Year Member



I have an .htaccess that sends things like

[mysite.com...]

to [mysite.com...]

The .htacces file worked fine on my old server on Ensim, but on DirectAdmiin has some issues... It doesn't seem like the rewrite rule geets executed, and I just get a 404 error.

here is the .htaccess file.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^shop/product/(.*)/(.*).html product.php?ID=$1

(I'm still testing it on my new server that has not propagated...
[111.111.111.11...]
Does that have anything to do with it?. I didn't think so, but...)

jdMorgan

3:33 am on Jul 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd contact the host and ask them. Best guesses would be:
  • You're not allowed to use mod_rewrite.
  • mod_rewrite is not loaded.
  • AllowOverride does not allow you to override Options settings or modify FileInfo.
  • If Apache 1.x, PHP is (incorrectly) listed after mod_rewrite in the module load list. (Apache 1.x Execution priority is the opposite of loadmodule order, so in this case, mod_rewrite would never run for requested php files.)

    Try a simple rewrite to eliminate all unnecessary variables. Something like:


    RewriteRule ^foo.html$ /some_static_page.html [L]

    If you request foo.html, you should see the contents of some_static_page.html.

    Reviewing the Apache docs for the AllowOverride, Options, and LoadModule directives may be useful.

    Jim

  • kenfused

    4:00 am on Jul 6, 2005 (gmt 0)

    10+ Year Member



    Well, mod_rewrite seems to be ok...
    I tested your one line .htaccess and that does work!

    My script includes;

    RewriteRule ^shop/category/(.*)/(.*)/(.*)/(.*) shop.php?query=$1&query2=$2&query3=$3&query4=$4

    But somehow I'm still hitting the 404 error, instead of getting to the page /shop.php?query=$1&query2=$2&query3=$3&query4=$4

    THANKs for any help!

    jd01

    4:07 am on Jul 6, 2005 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    RewriteRule ^shop/category/(.*)/(.*)/(.*)/(.*) shop.php?query=$1&query2=$2&query3=$3&query4=$4

    You might try a hard ending ($) on the left side of the rule, and a preceding / on the right side of the rule as required in the .htaccess file:

    RewriteRule ^shop/category/(.*)/(.*)/(.*)/(.*)$ /shop.php?query=$1&query2=$2&query3=$3&query4=$4 [L]

    Justin

    [edited by: jd01 at 4:07 am (utc) on July 6, 2005]

    jd01

    4:07 am on Jul 6, 2005 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    Oops!

    kenfused

    4:21 am on Jul 6, 2005 (gmt 0)

    10+ Year Member



    Hi Jd thanks for your help...

    Seems like the problem is that I have used your other suggestion from another post... I put an .htaccess file in the directory

    www.mysite.com/shop/

    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(index\.html)?$ /shop.php [R=301,L]

    I Want to have the following behaviors (in addition to having the above mod_rewrites):

    People who go to [mysite.com...] or [mysite.com...] to to automatically to
    www.mysite.com/shop.php

    IF I remove the .htaccess file from the directory /shop/ then the rewriterules for the other rules work! Now what? Seems like I can get one thing working, OR the other, but not both!

    kenfused

    5:21 pm on Jul 6, 2005 (gmt 0)

    10+ Year Member



    Fixed it!

    Took the .htaccess out of the /shop directory, then changed the redirect and put that info in the .htaccess file of the main root directory!
    Thanks JD

    jdMorgan

    7:46 pm on Jul 6, 2005 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    OK. It may have been possible to make the two-htaccess-file solution work with the addition of

    RewriteOptions inherit

    at the beginning of the .htaccess file in /shop.

    Jim