How to Perform a 301 Redirect Using .htaccess - Advantage Media Group

How to find all the pages an active website has

  1. Go to https://www.xml-sitemaps.com/ and type in the URL of the website you want to download the sitemap for. When it’s finished, press “View Sitemap Details”
  2. Then under ‘Sitemap Preview’, copy everything.
  3. In an Excel spreadsheet, click ‘A1’ and press paste. Delete the “Last Mod” and “Priority” column.
  4. Then go CTRL + F and search https://yourbusinessurl.com.au/
  5. In the search bar in the top right hand corner, click the little arrow next to the magnifying glass, then press ‘Replace’.
  6. DO NOT write anything in ‘Replace with’, and press ‘Replace All’
  7. What’s left should be the last part of the URL i.e. if the webpage is https://advantagemediagroup.com.au/Blog/ the only part left will be Blog/

How to create 301 redirect links

  1. In the excel spreadsheet, write “Old URL” in A1, and “New URL” in A1 and “Redirect” in C1. Paste the below code into ‘C2’: “RewriteCond %{QUERY_STRING} ^$ “&CHAR(10)&”RewriteRule ^”&A2&”$ “&B2&”?  [L,R=301]”
  2. Identify any of the old URLs that won’t be appearing on the new site and create a list of where these old pages should be redirected to. Put these into column B, starting at B2.
  3. Click C2, where you have pasted the formula, and click and hold the bottom right corner of the cell. Drag down until it is parallel with all of the URL’s you have entered in rows A and B. It will create a sentence like: RewriteCond %{QUERY_STRING} ^$
    Rewriterule ^example-old/$ /example-new/?  [L,R=301]

  4. Copy and Paste all of the new formed redirects from column C, into a word document.
  5. In the word document above all the redirects, write “RewriteEngine On”

Creating the 301 Redirect in cPanel using .htaccess

  1. Find the cPanel URL, and Log in. If you do not know your cPanel URL, search the website /cpanel, e.g. https://advantagemediagroup.com.au/cpanel
  2. Once logged in, go to ‘File Manager’ > Public_Html > Click settings in the right hand corner > ‘Show hidden files’ > save > find .htaccess > right click > edit
  3. At the very top of this screen copy and paste all your above redirects from word. Save.
  4. Try searching the old URL and see if it redirects.