homepage Welcome to WebmasterWorld Guest from 50.19.33.5
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Get mod_rewrite correct before upload
ukgimp




msg:1524553
 2:53 pm on Jul 9, 2002 (gmt 0)

Hello

I am trying to get with the thoery and practice of using the mod_rewite command

I have httpd access and .htaccess.

The original URL is in the following form:

www.mydom.com/show_full.htm?rec=xyz

I would like to make it:

www.mydom.com/mathematics/xyz.htm

I am trying to get to grips with the rewrite rule. Here is what I have come up with already. Am I on the right path?

RewriteRule ^(.*)mathematics/(.*) $1showfull.htm?rec=$2

I have a feeling that I am missing one side of the coin. Am i correct in saying that there needs to be two instances of a rewrite. One when the URL is presented and one when it is clicked so that the correct parameters are parsed out.

Any help.advice appreciated.

Richard

 

jdMorgan




msg:1524554
 5:13 pm on Jul 9, 2002 (gmt 0)

ukgimp,

The URL rewrite takes place when a resource (page, image, script) is requested, so
there is only one instance needed.

"
The original URL is in the following form:
www.mydom.com/show_full.htm?rec=xyz
I would like to make it:
www.mydom.com/mathematics/xyz.htm"

The following *might* work to accomplish what you describe:

RewriteRule ^show_full.htm\?rec\=(.*)$ mathematics/$1.htm [R=301]

The first part of the rule is the initial pattern, the second part is the
desired result. Only one substitution is needed, thus only one (.*) - $n pair
is needed.

Have you read the documentation on the Apache.org web site yet? There are two
long mod_rewrite documents there which are very helpful if you use them to
decode some of the examples you find here on WebmasterWorld.

Also should mention that the "\" character is used to escape certain characters
that have special meaning to the regular-expressions patten matching used by
mod_rewrite. In the rule above, I escaped both "?" and "=". "?" must be escaped
in this way - but not sure about "="; It won't hurt to precede it with "\"
anyway...

The "[R=301]" at the end of the rule will make this a permanent redirect. Use
it for testing, as it will force your browser to refetch the page from the
rewritten address, and you will see the results of your rewriterule in your
browser's address bar. You can then remove it when you get things working.

Hope this helps.
Jim

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved