BleepingComputer.com: Mod_Rewrite

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Mod_Rewrite

#1 User is offline   Billy O'Neal 

  • Bleepin Engineer GRADUATE
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Malware Response Instructor
  • Posts: 10,403
  • Joined: 17-January 08
  • Gender:Male
  • Location:Cleveland, Ohio

Posted 19 November 2008 - 09:01 PM

Hello :thumbsup:

I'm trying to redirect the folder /BleepingComputer to /forums, and would like to do so using a 301 redirect. Here's what I've tried in my HTACCESS file:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/BleepingComputer(.*) /forums$1 [R=301]


What am I messing up?

EDIT: That .htaccess is on the root directory of my server.

Billy3

This post has been edited by Billy O'Neal: 19 November 2008 - 09:06 PM


#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 19 November 2008 - 09:36 PM

Mod_Rewrite is tough sometimes. I'll see if I can help, but I have to warn you, I am woefully inadequate when it comes to this.

My first recommendation would be to enable logging, so something like this:
RewriteEngine on 
RewriteLog /etc/httpd/logs/rewrite.log
RewriteLogLevel 9


Of course, you can change your log location to anywhere you desire.

Now for the part I am a little fuzzy on. A rewrite rule needs a condition, as well as a rule. You have the rewrite rule portion, but you are not telling it what it needs to match. There is a geat cheat sheet here:
http://www.addedbytes.com/download/mod_rew...t-sheet-v2/pdf/

So if you have a folder called bleepingcomputer (or whatever), I would try something like this:
RewriteCond %{REQUEST_URI} ^(.*)myservername\.com\BleepingComputer 
RewriteRule ^(.*)$ http://www.bleepingcomputer.com/forums/


IIRC, the first line tells mod_rewrite what sort of incoming request you are looking for. In this case, it is an incoming URI that is requesting a specific folder.
The next line is the rewrite rule.


This is the forum that I use for my rewrite questions. Once you get it sorted, please post what you did. I am sort of curious since I have never had need to try what you are doing.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   Billy O'Neal 

  • Bleepin Engineer GRADUATE
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Malware Response Instructor
  • Posts: 10,403
  • Joined: 17-January 08
  • Gender:Male
  • Location:Cleveland, Ohio

Posted 19 November 2008 - 10:10 PM

Hello, Groovy :flowers:

Wow.. thanks for the through reply! *Bill bookmarks...

Got it working. Rather than Mod_Rewrite, I used mod_alias. Here's what I did:
Redirect 301 /BleepingComputer http://billy-oneal.com/forums

Duh! :thumbsup:

*Bill kicks self for making the problem 5 times more complicated than it had to be

Thanks :trumpet:

Billy3

#4 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 19 November 2008 - 10:11 PM

Quote

*Bill kicks self for making the problem 5 times more complicated than it had to be


I pretty much do that on a daily basis...... :thumbsup:
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users