Forum Moderators: phranque

Message Too Old, No Replies

Porting html to wordpress 301's Question

         

gorwell

1:13 am on Jan 8, 2010 (gmt 0)

10+ Year Member



I have ported a static html site to wordpress. I have switched hosts, so they are both on different hosts (will retain same domain name). Once I fine tune the redirects/rewrites I will switch domain names.

My question: I am trying to keep URL structure as consistent as possible, so "something.com/one-two.html" is now "something.com/one-two/"

I am using:

RewriteRule ^([^.]+)\.html$ http://www.example.com/$1/ [R=301,L]

to do this. It appears to be working. Is this kosher? But, it only works when I have the old .html file on server. Is that standard practice, I--naively, maybe--thought I could just do 301s in the htaccess file and leave the old .html files to vanish into thin air. Do I need to keep the old HTML files on server? Then once the rewrites have taken effect, remove them?

Or is there another method of rewriting that I can use that will work on non-existent files.

[edited by: jdMorgan at 2:51 am (utc) on Jan. 8, 2010]
[edit reason] example.com [/edit]

jdMorgan

2:49 am on Jan 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The existence of a file is not usually required for a URL redirect to function. Understand that you are redirecting URL-requests, not file requests, so whether a file exists or not is irrelevant as long as you don't have other rules or code that acts on non-existent files and precedes this rule.

So look for other rules ahead of this one that check for file- and/or directory-exists -- i.e. lines starting with

 RewriteCond %{REQUEST_FILENAME} 
.

If there are none, then perhaps you have content-negotiation enabled, and its grabbing the request because you've used "directory-naming syntax" for your new URLs (they end with a slash and are therefore presumed to be directories, not files.) If this is the case, then adding

 Options -MultiViews 

ahead of your rules (or combining that setting with any previous Options settings) should fix the problem (as well as speed up the server).

Jim

gorwell

5:21 am on Jan 8, 2010 (gmt 0)

10+ Year Member



Blah. For some reason, I thought it worked. But, it's still only for those pages I have the .html page on server.

Oh and I do have %{REQUEST_FILENAME}; it's for wordpress

## WORDPRESS ###
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

jdMorgan

8:16 am on Jan 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right, so where's your new rule in relation to that WP code?

Jim