Home › Forums › BulletProof Security Pro › Redirect all old HTML pages to new website pages
Tagged: redirect html pages, redirect index.html
- This topic has 22 replies, 3 voices, and was last updated 10 years, 11 months ago by
AITpro Admin.
-
AuthorPosts
-
Richard
ParticipantUsing the tutorial provided, I entered the following 301 redirect into the box at the end of Custom Content:
# Redirect 404 errors that show up in Google Webmaster Tools RedirectMatch 301 ^/Newsletterc.html$ http://applying-the-law-of-attraction.com/classic-law-of-attraction-collection/$1
I have updated the file and confirmed the redirect has been added to the file:
# IMPORTANT!!! DO NOT DELETE!!! the END WordPress text below # END WordPress # CUSTOM CODE BOTTOM HOTLINKING/FORBID COMMENT SPAMMERS/BLOCK BOTS/BLOCK IP/REDIRECT CODE RedirectMatch 301 ^/Newsletterc.html$ http://applying-the-law-of-attraction.com/classic-law-of-attraction-collection/$1
The page is not being redirected. I have converted from a standard html site to a WordPress site.
Thanks!
AITpro Admin
KeymasterThe backreference you are using is not correct. You are redirecting to this URL which is probably not what you want to do.
applying-the-law-of-attraction.com/classic-law-of-attraction-collection/Newsletterc.html
Please post what you are trying to do and I can then provide the correct Redirect code/rule.Richard
ParticipantI have had my html site upgraded to a responsive WordPress site so all of the old url’s need to be redirected to the new. The url from above used to be a valid page but is no longer since the transfer of the site. The page above is only one example, I wanted to get one working before I entered the rest.
Thanks,
DickAITpro Admin
KeymasterTo redirect all old HTML website pages to your new site’s URL structure you would use this code below. If your URL structure is 2 levels deep then you would use the
/$1/$2
RedirectMatch code. If your URL structure is 3 levels deep then you would use the/$1/$2/$3
RedirectMatch code, etc.Source: http://forum.ait-pro.com/forums/topic/htaccess-redirect-code-where-do-i-add-redirect-htaccess-code/
RedirectMatch 301 ^/([^/]+)/([^/.]+)\.html$ /$1/$2/ RedirectMatch 301 ^/([^/]+)/([^/]+)/([^/.]+)\.html$ /$1/$2/$3/
Or if you need to limit it by Host (domain name), you can use mod_rewrite:
RewriteCond %{HTTP_HOST} sitename.com [NC] RewriteRule ^([^/]+)/([^/.]+)\.html$ /$1/$2/ [R=301,L] RewriteCond %{HTTP_HOST} sitename.com [NC] RewriteRule ^([^/]+)/([^/]+)/([^/.]+)\.html$ /$1/$2/$3/ [R=301,L]
Richard
ParticipantI apologize, I don’t understand how to apply the code provided.
If I want to redirect:
applying-the-law-of-attraction.com/Your-Life-Purpose.html
to:
applying-the-law-of-attraction.com/step1/How would that look using your example?
Thanks again,
Dick IngersollAITpro Admin
KeymasterYour reply was flagged as Spam and has been unspammed. The code above would be used to redirect all old html pages dynamically to your new site pages/structure. If what you want to do instead is individual html page redirects then using the example URL’s you posted above, the RedirectMatch code would be this below. There is not a $ backreference at the end of the redirect to URL because you want the redirect to go to / point to /step1/ and not point to “Your-Life-Purpose.html” in the new redirected URL.
RedirectMatch 301 ^/Your-Life-Purpose.html$ http://applying-the-law-of-attraction.com/step1/
Richard
ParticipantPerfect!
Thanks for all of your help,
Dick IngersollAITpro Admin
Keymaster[Topic post manually moved to this relevant existing Topic]
I noticed today that my domain at index.html or any other folder throws a 404 error. I would really like to 301 redirect those pages, especially mysite.com/index.html since there will be good link juice to forward to my domain.
I had an HTML static site in the past and I just recently switched to a wordpress site. I installed wordpress it in its own directory. I believe this is causing me issues with placing the correct code in the right spot.
So in other words, I would like to permanently redirect: mysite.com/index.html to mysite.com or mysite.com/folder/index.html to mysite.com/folder/
This is the code I used. I tried this in the htaccess file in the root directory of the domain and it didn’t work. I tried different versions and 301 redirects and kept breaking my site, so I just thought some smart people here would know since it may need to be rewritten and go in the htaccess folder where the site is installed. See code below.
# REDIRECT REQUESTS FOR INDEX.HTML IN ANY DIRECTORY TO "/"IN SAME DIRECTORY RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/ RewriteRule ^(([^/]+/)*)index\.html$ http://www.mysite.com/$1 [R=301,L]
I’m wondering if URL in that that last line should be
http://www.mysite.com/wordpress/$1
or is this code totally wrong?
AITpro Admin
KeymasterSee this method in this Forum Topic above to redirect all old HTML pages to new WordPress Posts or Categories: http://forum.ait-pro.com/forums/topic/301-redirect-problem/#post-12714
Rob
ParticipantI’m not trying to redirect every HTML page on my old site. I didn’t keep the old folder structure. I completely changed my URL’s because my old HTML pages were not very good for SEO purposes. I’ve redirected my old pages using standard Redirect 301 in htaccess file in my domains root folder, which works fine.
The problem I’m having is with index.html. My biggest concern is with the this file in the site root:
http://www.mysite.com/index.html
. That use to be home page file in the static site though it would redirect tohttp://www.mysite.com
. Right now the URLhttp://www.mysite.com/index.html
gives a 404 error.My site is 12 years old and I have a lot of people over the years that linked to our site using that exactl URL unfortunately. I want to 301 redirect it permanently so that this link does not 404 and I get link juice passed on for SEO purposes. I’ve tried using the code above and it doesn’t work. I’ve also tried this:
Redirect 301 /index.html http://www.mysite.com/
The simple code above throws a redirect loop and breaks my site. Let me again emphasize that wordpress is installed in its own folder and not inside of root. Thanks again for looking at this.
RobAITpro Admin
KeymasterThen keep this really simple and use RedirecMatch .htaccess code and NOT Redirect like this example code below. I have a feeling you are not creating a new .htaccess file for this scenario and are trying to do this from your WordPress website, which will not work of course. You need to create a new .htaccess file in your website root folder or if you have a GWIOD (Giving WordPress Its Own Directory) WordPress site and you have an existing root .htaccess file for your GWIOD website then you will need to create the “redirect” in the existing site root .htaccess file and NOT your WordPress website root folder .htaccess file.
RedirectMatch 301 ^/some-file.html$ http://www.example.com/redirect-to-here-wherever-here-is/ RedirectMatch 301 ^/some-file.html$ http://www.example.com/
This is the scenario/website structure I am guessing you have setup by the clues you have posted.
/gwiod-site – your WordPress installation folder is here in this example folder named “gwiod-site”.
/ – this is the site root folder
/index.html – your old index.html file is either here or was here before.For WordPress GWIOD sites you have 2 .htaccess files: 1 in the site root folder and 1 in your WordPress installation folder.
/.htaccess and /gwiod-site/.htaccess
The .htaccess file where you need to add your RedirectMatch .htaccess code is: /.htaccessRob
ParticipantYes, you are correct about the strucutre. And yes, I have the HTML pages redirected in /.htacess and they work as intended. However, this code below does not work and breaks the site by causing a redirect loop.
RedirectMatch 301 ^/index.html$ http://www.mysite.com/
AITpro Admin
KeymasterWhere are you adding that RedirectMatch code? Which .htaccess file? RedirectMatch .htaccess code can go at the very bottom of your .htaccess file since it is stand-alone (not loop/rewriting dependent).htaccess code. At this point I would like to know your actual site architecture and not try guessing anymore. Please post your exact site architecture.
Example:
/WordPress is installed here
/this is where my index.html is or was
These are where my .htaccess files are X1, X2, etc.
I am adding the RedirectMatch code here: be very specific and exact.Rob
Participantmysite.com/wordpress/ is where wordpress is installed
mysite.com/wordpress/.htaccess is where the root BPS file resides (begins with # BULLETPROOF .50 >>>>>>> SECURE .HTACCESS )
mysite.com/.htaccess currently has a list of Redirect 301 codes that function correctly such as:Redirect 301 /page.html http://www.mysite.com/new-page/
mysite.com/.htaccess is where i tried to add your suggestion, but the site breaks:
RedirectMatch 301 ^/index.html$ http://www.mysite.com/
AITpro Admin
KeymasterAlso depending on which web Host you have (GoDaddy for sure) you need to add the folder name where the domain exists in the RedirectMatch code. This can be confusing. The folder name is: /example.com and the website domain URL is also example.com.
Example:
RedirectMatch 301 ^/example.com/index.html$ http://example.com/
Reference: http://forum.ait-pro.com/forums/topic/go-daddy-redirect-htaccess-code-no-longer-working/
-
AuthorPosts
- You must be logged in to reply to this topic.