301 redirect in htaccess not working


#1

I want to convert .htm pages to .php one by one at first.
So I tried redirect or rewrite in htaccess, and they both don’t seem to work, any suggestions appreciated.

Redirect 301 /home/username/evevancouver.ca/tv.htm http://www.evevancouver.ca/tv.php
(where username is my username)

or

Rewrite Rule ^tv.htm /tv.php [R=301,L]

goes to 500 internal server error

I am using vi to edit .htaccess

Thanks
Audrey


#2

I believe the ‘source’ file for the redirect in referenced from the document root (evevancouver.ca/), so try…

[color=#0000CC]Redirect 301 tv.htm http://www.evevancouver.ca/tv.php[/color]

Edit: If you are changing your .htm files to .php simply to allow you to have php code on those pages, you might find the thread linked below interesting, which explains how to enable php code in .htm files.

http://discussion.dreamhost.com/showflat.pl?Cat=&Board=forum_programming&Number=71919&page=&view=&sb=&o=&vc=1

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#3

I tried the ‘Redirect 301…’, however it did not work.

After writing to dreamhost tech, they removed the space between Rewrite and Rule, which is working now.

RewriteEngine on
RewriteRule ^tv.htm /tv.php [R=301,L]


#4

That is strange, I use .htaccess Redirects all the time and they work fine. You just need to make sure the source is referenced from the document root, while the destination needs to be a full URL.

Just looking at the example I gave previously, I seem to have forgot a leading slash. I am not sure if the slash is required, but it may be.

[color=#0000CC]Redirect 301 /tv.htm http://www.evevancouver.ca/tv.php[/color]

As I said in my previous reply; If your sole aim in changing the files from .htm to .php is to allow you to use PHP code in your pages, I would advise that you simply enable PHP parsing in .htm files, rather than having lots of redirects.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#5

Question:
try to build a simple .htaccess…
I’m speaking with you Mark…I’m saying this because it seems that my .htaccess doesn’t work anymore.
I hope is DH fault this time. :slight_smile:

Cupons:[color=#0000CC]MAO_HALFPRICE[/color] : pay only half of the price (L1 plans only) MAO97 get 97$ back


#6

I’ve read your last post a few times and I am probably stupid, but I can’t see the actual question. :s

The redirect in my last post should work fine, it will redirect any access to www.evevancouver.ca/tv.htm to www.evevancouver.ca/tv.php

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#7

Sorry, no question there.
It’s just that I was experimenting with .htaccess and it didn’t work for me too, so I was telling you to test .htaccess too.

:slight_smile:

Cupons:[color=#0000CC]MAO_HALFPRICE[/color] : pay only half of the price (L1 plans only) MAO97 get 97$ back


#8

Ah, OK, I thought you were asking a question, sorry for the confusion.

I just tested a 301 redirect that I’ve had active on one of my domains for a few months, it appears to still work fine.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#9

Well…so apparently is my simple .htaccess that is shitty.
But I think that yesterday I had bad luck too because apache wasn’t working all the time.

here it is

RewriteEngine on
RewriteRule / http://blog.xxx.com/? [R=301,L]

(I copied it from somewhere on the net)

Cupons:[color=#0000CC]MAO_HALFPRICE[/color] : pay only half of the price (L1 plans only) MAO97 get 97$ back