Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Mod-rewrite and .htaccess question



8:30 pm on Jun 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

What is the code to put in .htaccess to get


to show up as


With or with out .html at the very end.

The best I can get it right now is

RewriteEngine On
RewriteBase /cgi-local/directory/
RewriteRule ^file_name.html$ file_name.cgi




9:02 pm on Jun 20, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member


When processing a server-internal rewrite, mod_rewrite changes a requested URL into a pathname for use within the server, before your script runs.

I suspect you are trying to make your URLs more search-engine friendly. If that is the case, then it is up to your script to output search-engine friendly URLs, and you would then use mod_rewrite to translate those URLs -- when requested by the client (browser or SE 'bot) -- back into the "unfriendly" form that you need to call your script.

In case you're doing something different, here's an example for one of the rewrites you asked for:

name.cgi?item=number&type=Search -> name/item/number/type/Search

RewriteCond %{QUERY_STRING} ^([^=]+)=([^&]+)&([^=]+)=(.+)$
RewriteRule ^name\.cgi$ /name/%1/%2/%3/%4 [L]

Ref: Introduction to mod_rewrite [webmasterworld.com]



9:29 pm on Jun 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Is there a different permission setting when you do mod-rewrite? When I get an error message, this is what it gives out. (The normal script URL works fine.)


CGIWrap encountered an error while attempting to execute this script:

Error Message: Permission denied
Error Number: 13

This message usually indicates there is a problem with the script
itself. Often this indicates either that the #! line of the script is
incorrect, or the script was uploaded in binary mode instead of ascii
mode. Check to make sure that the script does not have control-M's at
the end of every line. That will prevent it from executing. An easy
fix that takes care of this most of the time is to put '#!/.../perl
--' instead of '#!/.../perl' on the first line of the script. This is
typically a problem if the script was edited or uploaded from a
DOS/Windows/Macintosh station to a unix based server.

If you are not the owner of this script, please forward this error and
the URL that caused it to the script owner. That is often the
component in the URL right after /cgiwrap/.


3:24 am on Jun 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Can't edit......

I got it working!

RewriteEngine on
RewriteBase /cgi-local/directory/
RewriteRule ^store\-mode\-(.*)\-id\-(.*).html$ store.cgi?mode=$1&id=$2
RewriteRule ^store\-mode\-(.*).html$ store.cgi?mode=$1
RewriteRule ^store\-item\-(.*)\-type\-Search.html$ store.cgi?item=$1&type=Search


Featured Threads

Hot Threads This Week

Hot Threads This Month