Home > database >  Changing my website from dynamic CMS to static HTML. Should I 301 redirect or use other methods?
Changing my website from dynamic CMS to static HTML. Should I 301 redirect or use other methods?

Time:01-20

I am changing my website from a dynamic CMS-system (Umbraco) to a static classic .HTML. It is the on the same domain, but the URL will change.

Example: The URL is changing from:

www.example.com/information

To:

www.example.com/info.html

My question is: What is the best way to redirect while keeping the best SEO page rank.

I am thinking about 301 redirect through .htaccess, but I am not sure if I should redirect my new to .html urls to the old dynamic …/example - or the other way?

Or maybe there is a different better way?

I do have a fine 404.

Also I need the right redirect code for .htaccess - if that's the right way.

I hope you guys can help me out.

I haven't try anything out yet, because I don't wanna do 301 before the site go live.

CodePudding user response:

You need to implement 301 redirects from the old URL to the new URL in order to preserve SEO and ensure that any "old" links that have been bookmarked or linked to from other websites still work.

Exactly how you implement the 301 redirect (either in your server-side script or in .htaccess) does not really matter. However, if you are moving to an entirely static site then .htaccess is likely the only option you have.

I am not sure if I should redirect my new to .html urls to the old dynamic …/example - or the other way?

You need to redirect from the "old" URLs to the "new" URLs that you are using/linking to on the new site. (It makes no sense to redirect the other way as that would just break everything!)

You can probably just use the simple mod_alias Redirect directive.

For example, to 301 redirect from /information to /info.html you could do the following:

Redirect 301 /information /info.html

Bear in mind that 301 redirects are cached persistently by the browser. To prevent caching issues it is advisable to test first with a 302 (temporary) redirect.


Have you considered keeping the same URLs? This would obviously negate the need for implementing redirects. You could employ URL-rewriting if the underlying file is called info.html. For example, using mod_rewrite:

RewriteEngine On

RewriteRule ^information$ info.html [L]

The above would internally rewrite a request for /information to info.html. The user only sees /information in the browser address bar, but info.html is served from your site.

Taking this further, it would be easier if the new "file" is simply the same as the old URL, just with a .html extension. For example, the URL is /information and the underlying file is information.html. You can then use a single rule to rewrite all your URLs. For example:

RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^([^/.] )$ $1.html [L]

The above assumes the old URLs do not contain additional slashes (ie. consist of a single path segment. In other words, all files are in the document root) and do not contain dots.

CodePudding user response:

White

I finally got my page ready to go live, and i changed all my new URLS to the same name as the old URL, just with a .html extension - as u said. After that i used:

RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^([^/.] )$ $1.html [L]

And it works fine.

I do have a question about if a "RewriteRule ^(.*).html$ /$1 [L,R=301]" would be better? I mean both "/page.html" and "/page/" works, and this could mess with my former SEO ranking?

Also: what do u think of this:

RewriteCond %{THE_REQUEST} /([^.] )\.html [NC]
RewriteRule ^ /%1 [NC,L,R]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]

RewriteRule ^(.*)\.html$ /$1 [L,R=301]

//MM

  • Related