Forum Moderators: phranque
The basic .htaccess commands used to create SEF URLs are
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*) index.php
Easy enough...The commands basically state if the requested filename isn't a file or directory, then process the rewrite rule.
The way the CMS is setup, if a file that does not exist and does not match any Joomla content is requested, it is redirected back to the homepage (I know not ideal, but it's not a big deal with these sites).
Anyway, now I need to incorporate another script into this setup. This script resides in the cgi-bin.
For some reason, when I place a file, any file into the cgi-bin, the above RewriteCond statements fail. By that I mean, if I try and access them such as
http://www.example.com/cgi-bin/myscript.cgi
It automatically gets the 301 redirect back to the homepage as if the file didn't exist.
If I place the file anywhere else in the public_html folder except for the cgi-bin, I can access it fine, but as soon as a file, any file is placed inside the cgi-bin, the redirect kicks in.
What is it about the cgi-bin that is causing these Conditions to fail?
If I place the file anywhere else in the public_html folder except for the cgi-bin, I can access it fine
but as soon as a file, any file is placed inside the cgi-bin, the redirect kicks in.What is it about the cgi-bin that is causing these Conditions to fail?
I don't think you quite understand. You NEED to be able to access files in the cgi-bin.
Not read them, but access and execute them. That's what the cgi-bin is for, to place executable files in (scripts).
The problem is, when I try and access them (read, "execute") the RewriteRule is kicking in even though the RewriteCond statements should not allow it to get that far.
Unfortunatley, while I've found a number of postings in various places from people having this problem, I have yet to find a posting about solving it. :(
Any help would be appreciated!
The SEF module has a section of code that handles the actual 301 redirect. Basically, it looks to see if the page name matches a component or content item of the CMS. If not, it issues the 301 to the homepage.
The thing is, unless I'm not understanding something, it shouldn't even get that far. The RewriteCond should see that the cgi-bin request is a file and skip the RewriteRule shouldn't it?
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteOptions Inherit
Jim
I have tried adding the RewriteCond you suggested previously and I am still getting the same results regardless of whether that line is added to the htaccess or not.
I also tried adding the "RewriteOptions Inherit" command you suggested with no luck.
Any other ideas? Thanks!
It shouldn't be this difficult to get one little thing to work! :)
Yes, you must have missed that in an earlier post. I had already tried the RewriteCond suggestion you made with no luck.
So...so far I have tried...
- Adding "RewriteCond %{REQUEST_URI}!^/cgi-bin/" to the .htaccess file
- Copying the entire .htaccess file to the cgi-bin
- Creating a new .htaccess file in the cgi-bin with "RewriteOptions Inherit" in it.
An interesting thing is I have this setup on about 10 different hosting providers and am having this exact same issue on all of them and none of the above options fixes the issue so it is not specific to this one host.
[edited by: Philosopher at 9:07 pm (utc) on Nov. 20, 2007]
Options +FollowSymLinks
RewriteEngine on
It is also possible that they've configured the cgi-bin directory with AllowOverrides None, in which case mod_rewrite (and several other modules) can't be used in that directory.
Jim
Just for the heck of it, what happens if you name that script in the cgi-bin with a .pl extension?
[edited by: Marcia at 3:56 am (utc) on Nov. 21, 2007]