Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Mod_Rewrite


  • Please log in to reply
3 replies to this topic

#1 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:11:05 PM

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

Edited by Billy O'Neal, 19 November 2008 - 09:06 PM.

Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:05 AM

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.

#3 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer

  • Topic Starter

  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:11:05 PM

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
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:05 AM

Posted 19 November 2008 - 10:11 PM

*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:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users