Forum Moderators: phranque

Message Too Old, No Replies

301-move: best code or all options the "same"?

         

deeper

9:42 pm on Oct 1, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi,
I intend to move two old small sites of about 50 pages each to Wordpress, staying at the same hoster.

Domains don't change, but all pages have now and will loose their .html-extension:
www.example.com/old-page-1.html --> www.example.com/old-page-1

Site 1 has no directory, all URLs are like www.example.com/old-page-1.html
Site 2 has additionally one directory, so some URLs are like www.example.com/old-page-1.html and others like www.example.com/dir/old-page-1.html

Wordpress root-directory won't be "/", but an extra folder "below".

Are the following codes more or less the "same"?
In another thread about internal rewrite I was told to use "$" after extension and that (.+) does not include URLs with hyphens. So Nr.1 is not sufficient, but the other three cover both sites equally?

 
Nr1: RewriteRule ^(.+)\.html$ $1 [R=301,L]

Nr2: RewriteRule ^([\w-]+)\html$ $1 [R=301,L]

Nr3: RewriteRule ^([\w-]+)\.html$ /index.php?$1 [R=301,L]

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

lucy24

11:56 pm on Oct 1, 2014 (gmt 0)

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



([\w-]+)\html
www.example.comm

Typos?

Rule #4 is the best for most situations. If none of your URLs ever have literal periods, you can express the pattern as ^[^.]+\.html. If your existing URLs might include directory slashes, make sure the pattern allows them. Patterns with non-final .+ or .* are generally the last resort.

Rule #3 is bad, bad because you're issuing an external redirect to "index.php" by name. That's exactly what you don't want to do. This target should be reserved for internal rewrites, part of the WP boilerplate.

Rules #1-#3 are missing the protocol-plus-domain, which should be a part of every external redirect. Otherwise people who asked for the wrong form of the hostname will get redirected twice.

deeper

2:27 am on Oct 2, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



([\w-]+)\html
www.example.comm

Typos?


Yes, "after-midnight-typos"
([\w-]+)\.html
www.example.com
are correct.


If your existing URLs might include directory slashes, make sure the pattern allows them. Patterns with non-final .+ or .* are generally the last resort.


Site 2 has one directory and therefore about 20 URLs like www.example.com/dir/old-page-1.html and additionally about 40 like www.example.com/old-page-1.html

Nr4 does not cover this for both sites properly? What code would you choose for site 1 and site 2 then?

Rules #1-#3 are missing the protocol-plus-domain, which should be a part of every external redirect. Otherwise people who asked for the wrong form of the hostname will get redirected twice.

What do you think is the moste probable mistake regarding this?

deeper

2:32 am on Oct 2, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



Sorry, "even-more-after-midnight-quote-mistake".

I don't see a way of correcting posts afterwards.