in reply to .Htaccess rewrites, Mod_Rewrite Help

so apache? Try mod_rewrite .... see apache forums :)
  • Comment on Re: .Htaccess rewrites, Mod_Rewrite Help

Replies are listed 'Best First'.
Re^2: .Htaccess rewrites, Mod_Rewrite Help
by aceofspace (Acolyte) on Dec 24, 2010 at 04:56 UTC
    I tried the followings in the .htaccess file:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteRule (.*)$ cgi-bin/profile.cgi?$1


    It does not work.

    What did I do wrong? Any suggestion?
      RewriteRule (.*)$ cgi-bin/profile.cgi?$1

      I'm very suspicious of catch-all rewrite rules. For one they disable the old URLs, and /cgi-bin/profile.cg?john then becomes /cgi-bin/profile.cgi?cgi-bin/profile.cgi?john internally, which looks very wrong.

      It does not work.

      How did it not work? Did your browser window dissolve itself in a shower of pink dots? or did the server start to burn? Or did you get any error message? If yes, what? Did you look into the server's log files?

      Fwiw mod_rewrite has the RewriteLog directive, and from that log you can usually tell what you did wrong. Of course you need to put some effort into it, which is not as convenient as asking in a forum, but if you solve it yourself it feels much more rewarding. I promise.

      What did I do wrong? Any suggestion?

      Contact apache support forum, they know apache

      Try something like this:

      RewriteEngine ON RewriteRule ^(.*)/?$ /cgi-bin/profile.cgi?$1 [L,QSA]

      Explaination:

      It's important to anchor the thing your trying to match, so use "^" to indicate the start and "$" to indicate the end. Since a URL may or may not end with a final "/", you need to use "/?" in the regex to indicate "optional trailing slash". The "L, QSA" means treat this as the LAST (that's the L part) rule. If your .htaccess file has rules after this one, they will be ignored - that's normally what you want, but you have to be careful. Sometimes you DO want multiple rules to be applied. The "QSA" means "append query string" - so any args get passed along to the new URL, rather than chopped off.