Welcome to Dream.In.Code
Getting Help is Easy!

Join 99,791 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,603 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



.htaccess: RewriteRule to .cgi doesn't work?

 
Reply to this topicStart new topic

.htaccess: RewriteRule to .cgi doesn't work?

girasquid
post 16 Nov, 2007 - 12:55 AM
Post #1


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,117



Thanked 5 times

Dream Kudos: 625
My Contributions


Hello, all.

I'm working on a project which involves custom RewriteRules that redirect the user to specific CGI pages. The rules look something like this:
CODE

RewriteRule ^story/(.+)$ story/$1.cgi [nc]

However, using that rule throws a 500 error.

I've read and re-read every guide on RewriteRule's I've been able to find, and I can't for the life of me seem to figure out what's going wrong here(if I don't add the .cgi at the end, it works fine - throwing a 404 because the file doesn't exist).

Does anyone know what I might have done wrong while writing this RewriteRule?

Thanks,
Girasquid

Edit:
After tweaking my rule, I have found that this line will work(inside the 'story' directory):
CODE

RewriteRule ^(.+)$ /$1\.cgi [NC,L]

However, that attempts to rewrite to /story.cgi - which is not what I want. I need to rewrite to the local copy. Removing the initial slash, however, throws a 500 error:
CODE

RewriteRule ^(.+)$ $1\.cgi [NC,L]

Taking out the escape on the . in .cgi also does not fix anything:
CODE

RewriteRule ^(.+)$ $1.cgi [NC,L]


Edit #2:
After some more testing, it would seem that it's the . in the .cgi that's breaking things. However, even after I escape the dot(\.), the problem persists.

This post has been edited by girasquid: 16 Nov, 2007 - 01:26 PM
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 16 Nov, 2007 - 02:04 PM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,289



Thanked 15 times

Dream Kudos: 2275

Expert In: Goofing Off

My Contributions


1.) Does the server have read permissions on that directory so that they are viewable?
2.) Can the cgi pages be directly loaded? It sounds like that's what you are doing. In some situations, the cgi exists beyond the root directory of the server, & must be referanced server side only.
3.) Are the cgi files executable? Assuming you are on a *nix system.
User is online!Profile CardPM

Go to the top of the page

girasquid
post 16 Nov, 2007 - 02:08 PM
Post #3


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,117



Thanked 5 times

Dream Kudos: 625
My Contributions


QUOTE(no2pencil @ 16 Nov, 2007 - 02:04 PM) *

1.) Does the server have read permissions on that directory so that they are viewable?
2.) Can the cgi pages be directly loaded? It sounds like that's what you are doing. In some situations, the cgi exists beyond the root directory of the server, & must be referanced server side only.
3.) Are the cgi files executable? Assuming you are on a *nix system.


The answer is yes, to all of those questions.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 7/25/08 01:51AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month
-->