Forwarding using .htaccess

software development

#1

I’ve been trying to get this to work for a couple days, so I was hoping someone here could help me out.

I recently moved servers and addresses and wanted to figure out a way of forwarding without losing my google standing. The issue is, since moving I’ve also changed the way I format my address. I’ve had a script written for me that is supposed to forward to the new location. The old address is formatted like this

http://www.slideaway.ca/modsuperstar/entry_243.php

but the new address

http://www.modsuperstar.ca/pivot/entry.php?id=243

The script I have is this

RewriteEngine On
RewriteRule ^modsuperstar/entry_([0-9]+).php$ redirect.php?request=$1

which leads to a page called redirect.php with this code

<?php $id = (int)$_GET['request']; // make sure that we're dealing with an integer... header('HTTP/1.1 301 Moved Permanently'); header('Location: |http://www.modsuperstar.ca/pivot/entry.php?id=|'.$id); exit; ?>

Now I’ve installed both on my server and it’s done nothing. Originally it yielded a 500 error, but now after deleting it and reinstalling it just loads the page.

I’m not very knowledgable with .htaccess, so any help on what I might be doing wrong here would be appreciated.


#2

What are the path symbols (|) doing in your location header?
Try to replace with the following:

header("Location: http://www.modsuperstar.ca/pivot/entry.php?id=$id");
Another solution, which I think is a lot nicer, is to do the entire redirect in one step in your rewrite rule:

RewriteEngine On RewriteRule ^modsuperstar/entry_([0-9]+).php http://www.modsuperstar.ca/pivot/entry.php?id=$1 [R=301]


[color=#000000]DreamHost Promo Code[/color]: [color=#CC0000]Save $50[/color] with the promo code DREAMTEAM


#3

I’ve now tried both methods and it still doesn’t work. Is there some way I should be uploading the files? What’s the proper chmod setting for .htaccess? I’ve been uploading them to the slideaway.ca/modsuperstar directory, should I be putting it elsewhere?


#4

I think you can set it to 644, unless you need it to be writable, in which case it should be 666 or higher.

I’m not sure if it needs to be in the slideaway.ca/modsuperstar directory or the slideaway.ca directory, but you can try both while you’re waiting. :slight_smile:

Jen
http://www.SassyDevil.com/


#5

I gave that a shot and still no luck. Is there something with the server configuration that is going wrong. Is there some test I can run to see if the .htaccess is even working?


#6

I found some .htaccess info in the Knowledge Base:
Various .htaccess samples and tutorials

You could try to make some other changes to your .htaccess file to see if it has any effect (like changing DirectoryIndex, ServerAdmin or enable password protection.

Otherwise, if none of the above gives any results, I would contact support.


[color=#000000]DreamHost Promo Code[/color]: [color=#CC0000]Save $50[/color] with the promo code DREAMTEAM


#7

I may have to contact support then. I just tried running some stuff on the server. I could get the custom error messages to work, showing me the .htaccess is working, but can’t get it to redirect in any way, shape or form.


#8

In the .htaccess in your root directory of www.slideaway.ca

this should be your redirect code:
RewriteRule ^modsuperstar/entry_([0-9] ).php http://www.modsuperstar.ca/pivot/entry.php?id=$1 [L,R=301]

with no other .htaccess file in the ‘modsuperstar’ directory of www.slideaway.ca

Hope that helps

===== EDIT =====
Not sure if
Options FollowSymlinks
needs enabling at Dreamhost for mod_rewrite to work
I have it set and have no problems
===== END EDIT ======

Steve

=========================
Click for [color=#CC0000]Dreamhost Server Options[/color]