homepage Welcome to WebmasterWorld Guest from 54.161.155.142
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod_ rewrite htaccess for dynamic pages to static pages
westloop




msg:1511995
 11:05 pm on Dec 20, 2002 (gmt 0)

I have tried to get this to work for over 5 hours, and finally figured I should see if anyone who knows how to do this could help me. This is what I need to do:

I have been trying to use mod_rewrite in the .htaccess file to make dynamic pages be static pages, I have only been able to get the base page to load, and can't get the other pages to load.

What I would like to get it to do is make requests to
[mydomain.com...] read
[mydomain.com...] and I have got that to
work a few times, however once I add more to the path such as
[mydomain.com...] or
[mydomain.com...] it
won't work.

Here is code simlar to what I have been using in the htaccess file, I am not
sure what I am doing wrong.

RewriteEngine On
RewriteBase /exec/store/
RewriteRule ^(.*)? /~totalmar/cgi-bin/cart.cgi/$1/$2
RedirectMatch ^$ /exec/store/$1/$2

I have tried reading the Apache guides at:
[httpd.apache.org...]
[httpd.apache.org...]

Only I am having problems still, I have tried to get this to work but can't get it to work. How can I fix it?

 

jdMorgan




msg:1511996
 12:29 am on Dec 21, 2002 (gmt 0)

westloop,

You might want to check out this post [webmasterworld.com] for some ideas.

I would recommend that your check to make sure you don't need to enable SymLinks, and make sure that you really need the RewriteBase directive. Examining your raw error log and looking at the rewritten file path is often useful in this regard.

If the above does not help, please post a more detailed description of what works, what doesn't work, and how it is malfunctioning.

Jim

<added>Also, several of your backreferences are undefined. i.e. $1 and $2 in the target URL are defined by the first and second parenthesized groups in the rewrite pattern. Your first rule is missing a definition for $2, and both $1 and $2 are undefined in your second rule. HTH.</added>

westloop




msg:1511997
 4:26 am on Dec 21, 2002 (gmt 0)

I am now trying this, it works for the base url. This calls the index.html file, however once another file is called or files in directories in this directory it doesn't work, and says it can't find the file.

RewriteEngine on
RewriteBase /
RewriteRule ^$ ~userbob/cgi-bin/cart.cgi/ [R]

I tried creating a symlink, but it won't work as the ~userbob/ is the name of the catalog, if I use a symlink it doesn't appear to know where to find the catalog and won't work.

Any ideas? Thanks

jdMorgan




msg:1511998
 4:47 am on Dec 21, 2002 (gmt 0)

westloop,

This combines the two functions - redirecting your site index page "/" to /~userbob/cgi-bin/cart.cgi/, and redirecting non-blank pathnames from /exec/store/whatever to /totalmar/cgi-bin/cart.cgi/whatever

RewriteEngine on
RewriteBase /
RewriteRule ^$ ~userbob/cgi-bin/cart.cgi/ [R,L]
RewriteRule ^exec/store/(.*)$ ~totalmar/cgi-bin/cart.cgi/$1 [R,L]

This is from your original description, so I'm not sure if that's what you want to do, but the above demonstrates the backreference you'll need to insert /~userbob/cgi-bin/cart.cgi/ into the path. The $1 refers to the contents of the (.*) on the left side of the second rule.

HTH,
Jim

westloop




msg:1511999
 4:59 am on Dec 21, 2002 (gmt 0)

I got it to work finally, I used:

RewriteEngine on
RewriteBase /
RewriteRule ^(.*) ~userbob/cgi-bin/cart.cgi/$1

jdMorgan




msg:1512000
 5:06 am on Dec 21, 2002 (gmt 0)

Cool!

If you add more rewrite rules in the future, stick a [L] flag on them to prevent them from interfering with each other.

Jim

westloop




msg:1512001
 8:52 pm on Dec 22, 2002 (gmt 0)

Thanks for the suggestion. I will do that.

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