|mod_ rewrite htaccess for dynamic pages to static pages|
| 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...] and I have got that to
work a few times, however once I add more to the path such as
Here is code simlar to what I have been using in the htaccess file, I am not
sure what I am doing wrong.
RewriteRule ^(.*)? /~totalmar/cgi-bin/cart.cgi/$1/$2
RedirectMatch ^$ /exec/store/$1/$2
I have tried reading the Apache guides at:
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)|
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.
<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)|
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.
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)|
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
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.
| 4:59 am on Dec 21, 2002 (gmt 0)|
I got it to work finally, I used:
RewriteRule ^(.*) ~userbob/cgi-bin/cart.cgi/$1
| 5:06 am on Dec 21, 2002 (gmt 0)|
If you add more rewrite rules in the future, stick a [L] flag on them to prevent them from interfering with each other.
| 8:52 pm on Dec 22, 2002 (gmt 0)|
Thanks for the suggestion. I will do that.