Forwarding using .htaccess

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

but the new address

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: ||'.$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.

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

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$1 [R=301]

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

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 directory, should I be putting it elsewhere?

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 directory or the directory, but you can try both while you’re waiting. :slight_smile:


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?

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

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.

In the .htaccess in your root directory of

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

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

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 ======


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