Forum Moderators: phranque

Message Too Old, No Replies

complex rewrite from a newbie

I am lost trying to get to my mod rewrite

         

cas_alterit

9:59 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Here is my environment.

I have an application that currently generates an HREF in the form of http:/www.good_app.com/cgi-bin/lmn.cgi/subdir/start.html?c=14

I have changed the HREF (for search engine reasons within our software) to generate on the output: http:/www.good_app.com/subdir/horses.html

I must use parameters within our software in order to process the data records. i.e. start.html?c=14

my rewrite rule looks like this:
RewriteRule ^horses.html$ /cgi-bin/lmn\.cgi/subdir/start\.html?c=14 [L]

I, of course, am getting back a Page Not Found 404 error.

My directory structure looks like this:

The site is loaded from this dir thru our config files
/home/usr/public/subdir

The binary of the software runs in this dir
/home/usr/public/cgi

The softare platform runs in this dir
/home/usr/public/private/subdir

the .htaccess file is in /home/usr/public/private/subdir

I expect I have things at the wrong level ---any help?

jdMorgan

10:21 pm on Jun 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First, you've escaped literal periods in the substitution URL where they should not be escaped, and you have not escaped them in the regular-expressions pattern where they should be escaped:

RewriteRule ^horses\.html$ /cgi-bin/lmn.cgi/subdir/start.html?c=14 [L]

Do you have any other RewriteRules that work? Did you set your Options and enable the RewriteEngine?

Jim

cas_alterit

10:48 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Thanks for the quick answer. I had the escapes the way you suggested earlier, but something I read had them reversed so it didn't work either way.

I have .htaccess files, but they only apply to user password/access rules. -- No rewrites. I do have the rewriteengine on, but I am not sure what Options have to be set. Where do i read about them.

jdMorgan

10:53 pm on Jun 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Everything is pretty-well covered in the Apache mod_rewrite and Apache core documentation.

Try this quick test:


Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteRule ^foo\.html$ http://www/google.com/ [R=301,L]

Request /subdir/foo.html from your server, and you should land at Google.

Jim

cas_alterit

11:17 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



OK I tried your test -- I put your rewrite rule in, but I still get file not found. I am sure the problem is in which subdirect i am putting the .htacess. Should I have rewriteengine on in .htaccess's higher up

g1smd

12:05 am on Jun 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you have absolute or relative URLs in the links on your pages?

I often have .htaccess only in the root folder.

cas_alterit

3:35 am on Jun 27, 2008 (gmt 0)

10+ Year Member



They are relative url's based on a data table. I do have the .htaccess on root folder of the account, which is correctly setup and translates the cgi-bin to hide it from the href.

jdMorgan

7:28 pm on Jun 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest that you try moving the "google" redirect posted above around, placing it into the .htaccess files long the filepath traversed when the server is resolving a requested URL.

You may also wish to try putting "RewriteOptions inherit" ahead of the rule itself.

Take a look at the server error log as well as the access log -- correlating the information in those logs files may be quite helpful in determining the problem. It is also possible that you cannot use mod_rewrite at your 'level' on this server.

Jim