Forum Moderators: phranque

Message Too Old, No Replies

rewrite rule to redirect /cgi-bin/(.*) to /cgi-bin/folder/$1

apache mod rewrite

         

edaindia

6:37 pm on Sep 1, 2009 (gmt 0)

10+ Year Member



the directory structure imposed by my hosting service provider was
/www/domain.com/all html files for domain1
AND
/cgi-bin/domain.com/all scripts

so when a user would access [domain.com...] he would actually run the foo.pl located at /cgi-bin/domain.com/foo.pl
Recently the requirement for cgi-bin was changed to
/cgi-bin/all scripts but I cannot move foo.pl to /cgi-bin because of conflict with another file with the same name.

so my previous URL changes to [domain.com...]
I have been trying the rewrite rule to internally redirect /cgi-bin/(.*) to /cgi-bin/domain.com/$1 without success.
my effort resulted in the htaccess at /www/domain.com/.htaccess being modified to contain the following lines

RewriteCond %{HTTP_HOST} www.domain\.com/cgi-bin/ [nc]
RewriteRule ^/cgi-bin/(.*)$ [domain.com...] [L]

I am getting a 404 with this rule for [domain.com...] Any insight on what i am missing?

jdMorgan

7:08 pm on Sep 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1) RewriteRule patterns in .htaccess should not start with a slash, so remove that slash.

2) A request for domain.com won't match a RewriteCond looking for a match on "www.domain.com", so remove the "www." from the RewriteCond pattern if you want to match the root domain as well as any and all subdomains.

3) Get a better host. Changes to URLs or filesystem architecture should never be imposed on hosting customers.

Jim