Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become an Expert!

Join 244,263 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,245 people online right now. 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
15 Nov, 2007 - 11:55 PM
Post #1

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,539



Thanked: 43 times
Dream Kudos: 825
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 - 12:26 PM

User is offlineProfile CardPM
+Quote Post


no2pencil
RE: .htaccess: RewriteRule To .cgi Doesn't Work?
16 Nov, 2007 - 01:04 PM
Post #2

Unix Ronin
Group Icon

Joined: 10 May, 2007
Posts: 10,438



Thanked: 198 times
Dream Kudos: 2725
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 offlineProfile CardPM
+Quote Post

girasquid
RE: .htaccess: RewriteRule To .cgi Doesn't Work?
16 Nov, 2007 - 01:08 PM
Post #3

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,539



Thanked: 43 times
Dream Kudos: 825
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
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 12:03PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month