Welcome to WebmasterWorld Guest from 23.22.79.235

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_ rewrite htaccess for dynamic pages to static pages

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

10+ Year Member



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?

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

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



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>

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

10+ Year Member



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

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

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



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

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

10+ Year Member



I got it to work finally, I used:

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

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

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



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

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

10+ Year Member



Thanks for the suggestion. I will do that.