Forum Moderators: phranque
none of them seemed to work so any help would be great :)
RewriteEngine on
RedirectCon %{REQUEST_URI} ^Count.cgi ¦ FormMailclone.cgi ¦ FormMail.cgi ¦ FormMail.pl ¦ addalink.cgi ¦ cgiecho ¦ cgiemail ¦ countedit.cgi ¦ domainredirect.cgi ¦ entropybanner.cgi ¦ entropybanner.cgiwrap ¦ entropysearch.cgi ¦ formmail.cgi ¦ formmail.pl ¦ guestbook.cgi ¦ helpdesk.cgi ¦ mchat.cgi ¦ randhtml.cgi ¦ randhtml.cgiwrap ¦ realhelpdesk.cgi ¦ realsignup.cgi ¦ scgiwrap ¦ signup.cgi)$
RewriteRule ^(.*)$ %{HTTP_HOST}%/nowhere.no
thanks in advance
First see if mod_rewrite works. In example.com/.htaccess, try:
RewriteEngine on
#
RewriteRule ^foo\.html$ http://www.google.com/ [R=301,L]
Note: If you're not putting your code in a .htaccess file (you didn't say), then add a leading slash to the RewriteRule pattern, making it "^/foo\.html$". This applies to RewriteRule patterns only.
If that doesn't work, then you may need to add a line:
[b]Options +FollowSymLinks[/b]
RewriteEngine on
#
RewriteRule ^foo\.html$ http://www.google.com/ [R=301,L]
If it does work, then try a simpler version of your desired rule, using either just the RewriteEngine directive, or also adding the Options directive -- whichever worked above:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{REQUEST_URI} ^/Count\.cgi$ [NC]
RewriteRule . http://%{HTTP_HOST}/nowhere.no [R=301,L]
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{REQUEST_URI} ^/(Count\.cgi¦FormMailclone\.cgi¦FormMail\.cgi)$ [NC]
RewriteRule . http://%{HTTP_HOST}/nowhere.no [R=301,L]
You may also wish to consider using an internal rewrite, rather than an external redirect. This avoids telling the (presumably-malicious) client what just happened. Instead of sending a redirect response to the client, it simply serves the alternate content from "/nowhere.no" -- without telling the client that the malicious request was detected:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{REQUEST_URI} ^/(Count\.cgi¦FormMailclone\.cgi¦FormMail\.cgi)$ [NC]
RewriteRule . /nowhere.no [L]
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{REQUEST_URI} ^/(Count\.cgi¦FormMailclone\.cgi¦FormMail\.cgi)$ [NC]
RewriteRule . - [F]
Be warned that mod_rewrite is not a high-level programming language; It does not allow you to enter your code "free-style." You must follow the documented syntax exactly, or risk taking your server down and/or ruining the rankings of your pages in search. I strongly recommend that you refer to the Apache mod_rewrite documentation [httpd.apache.org] while coding, rather than trying to use examples found in forums... even this one.
There are some other useful documents cited in our Apache Forum Charter as well (see links at top of this page).
Jim
RewriteEngine is on and i can rewrite pages just not the ones listed above in the alias cgi-sys directory.
i couldnt even get this to work:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{REQUEST_URI} ^/Count\.cgi$ [NC]
RewriteRule . [%{HTTP_HOST}...] [R=301,L]
there's extra spaces and stuff because i did a find and replace to remove some of the garbage from my desperate and even more ugly attempts. lol that was just an ugly sample of what i was trying to do.
This is one of the implications of the statement repeated in the documentation that ".htaccess is a per-directory configuration file.
Jim
currently i have:
Options +FollowSymLinks
RewriteEngine on
RewriteCond ^/Count\.cgi$ [NC]
RewriteRule . /nowhere.no [L]
in .htaccess which is in root web directory (public_html)
i am trying to redirect /cgi-sys/Count.cgi to page not found and as fast and invisible as possible.
thanks again for your help.
The code you just posted is still invalid because the RewriteCond is missing an argument. Please review the RewriteCond I posted previously above.
Jim