Forum Moderators: phranque

Message Too Old, No Replies

Redirecting users to new URL?

I'm rewriting my site, but all the URLs will be different...

         

Xedium

8:33 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



I'm in the process of rebuilding one of my websites, to use PHP with headers and footers and all that fancy stuff. The old version was just plain HTML, but it was managed by FrontPage (I'm sorry).

The problem is that all of the URLs for the site will change. What used to be /content.html would become /content.php

Since my site relies on direct links for many of its visitors, then I'm at risk of losing a lot of visitors if I don't pull this through correctly. What's the best way to seamlessly redirect users to the new URLs?

It'll probably have to be on a per-URL basis. Some URLs, such as /content/content.html will become /content/index.php, so a single rewrite probably won't work.

bill

3:58 am on Dec 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's nothing wrong with FrontPage. It's a great tool if you know how to use it correctly.

There's no need to switch extensions for your pages. Just parse your HTML as PHP [google.com].

physics

6:11 am on Dec 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to check out ISAPI Rewrite.

Xedium

12:26 am on Dec 27, 2006 (gmt 0)

10+ Year Member



I run on shared hosting (LAMP), and I'm 97.5% positive that I can't parse HTML as PHP.

bill

1:28 am on Dec 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you're on Apache and have access to the .htaccess file, then peruse through some of the threads I linked to above. Your certainty level will surely drop a few points. ;)

Xedium

10:03 pm on Dec 31, 2006 (gmt 0)

10+ Year Member



Now I'm 98% sure.

I tried everything at [webmasterworld.com...] but the most I got was an Internal Server Error. Looks like HTML as PHP won't be an option.

[edited by: trillianjedi at 11:10 am (utc) on Jan. 1, 2007]
[edit reason] Fixing URL [/edit]

alfaguru

3:15 pm on Jan 1, 2007 (gmt 0)

10+ Year Member



If your hosting supports mod_rewrite you don't need to parse HTML as PHP per se, instead you can simply rewrite all .html URLs to the equivalent .php, using a line like this in your .htaccess file:


RewriteRule ^(.*)\.html$ $1.php

Thus the URL "test.html" will cause the file "test.php" to be executed. You should also make sure all the links between pages use the .html version of each URL so visitors never see the 'wrong' variant.