homepage Welcome to WebmasterWorld Guest from 54.197.171.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Mod-rewrite and .htaccess question
Jesse_Smith




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

What is the code to put in .htaccess to get

name.cgi?mode=name
name.cgi?mode=name&id=number
and
name.cgi?item=number&type=Search

to show up as

name/mode/name
name/mode/name/id/number
and
name/item/number/type/Search

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

turning

name.cgi?mode=name
into
name.html?mode=name

 

jdMorgan




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

Jesse,

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]

HTH,
Jim

Jesse_Smith




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

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/.

Jesse_Smith




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved