LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-06-2004, 02:05 PM   #1
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Rep: Reputation: 30
Help me make this rewrite rule in Apache


What would be the rewrite rule to redirect a page from www.domain.com/cgibin/some_page.html to www.domain.com/cgi-bin/some_page.html? (cgi-bin is the keyworD)

Assume a general case, i.e. all cgibin's converted to cgi-bin's


I tried:

RewriteEngine on
RewriteRule ^cgibin$ cgi-bin [R]


but didn't appear to work!!

thanks in advance, ganninu..
 
Old 01-06-2004, 02:11 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Have you checked out the rewrite documentation for apache here: http://httpd.apache.org/docs/misc/rewriteguide.html

After making your changes, did you restart apache?
 
Old 01-06-2004, 02:17 PM   #3
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
Yes I did both of them....
 
Old 01-06-2004, 02:23 PM   #4
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Rep: Reputation: 30
Uhh. Try this:

RewriteEngine on
RewriteRule ^/(.*)cgibin(.*)$ /$1cgi-bin$2 [R]

Basically, your expression is looking merely for a request string exactly equal to cgibin. Since that is not what was being sent, it wouldn't work.

Instead, I made the one above that says this: Start with a / followed by 0 or more characters, followed by cgibin, preceeded by 0 or more characters until the end.

The replace string includes back-references, otherwise you'd be rewriting to another location other than what you intend.
 
Old 01-06-2004, 02:33 PM   #5
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
This would be good as well, right? -

RewriteRule (.*)cgibin(.*) $1cgi-bin$2 [R]
 
Old 01-06-2004, 02:40 PM   #6
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Rep: Reputation: 30
I believe that has the same functionality as what you wish to do. It is certainly the most generic instance.
 
Old 01-06-2004, 02:51 PM   #7
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
Ok thanks... my mistake was basically the subsitution part... This answer has taught me something important which i used to take for granted

By the way, I liked your wallpaper!!

ganninu
 
Old 01-07-2004, 01:57 AM   #8
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
Hi, I still got a problem!!! When enter this URL:
some_vhost.domain.net/cgibin/some_page.html

I am redirected to:
some_vhost.domain.net/data/httpd/vhosts/some_vhost.domain.net/httpdocs/cgi-bin/some_page.html

i.e. I get the extra data/httpd/vhosts/some_vhost.domain.net/httpdocs....

What is happening here, and how can i get rid of it?

Ganninu.

Last edited by ganninu; 01-07-2004 at 02:35 AM.
 
Old 01-07-2004, 08:30 AM   #9
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Try something like:
RewriteRule ^/(.*)/cgibin/(.*) /$1/cgi-bin/$2 [R,L]
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with Apache rewrite rules?? latino Programming 0 12-24-2004 02:09 AM
lopster v1.2.2 make error: No rule to make target `m4/glibc21.m4' Kropotkin Fedora 0 10-31-2004 11:19 AM
make: *** No rule to make target 'gconfig'. Stop. cswake Slackware 4 10-10-2004 12:13 PM
Exim4 rewrite rule for multiple email addresses Hcman Linux - General 3 10-09-2004 02:46 PM
How to make rule for make install and make uninstall melinda_sayang Programming 1 06-14-2004 05:58 AM


All times are GMT -5. The time now is 01:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration