.htaccess newby
-
Sorry to ask a really dumb question. I want to sort out a load of old 404 errors. I've exported the list of URL and I'm more than happy to go through that and work out what needs to go where.
After that my only option at the moment is to use the re-direct function in my WordPress install and do all the work manually. There are loads to do so I want to be able to upload all the re-directs.
I know I need to create a htaccess file and upload it. I know where to upload it.
This is where I get nervous. I need to get this file right. Is there a really obvious idiots file which I can use and then save as the correct file type? I've got all the URLs in a CSV at the moment.
Sorry for being a bit thick. Hope you can help.
-
Tested and all working!
-
Thanks for that.
All done now, fingers crossed!
Richard
-
Yeah, that looks to be the right file. So, in this case, I'd put the new redirects right after the current redirect.
redirect permanent /index.html http://www.global-lingo.com/index.php
PUT NEW REDIRECTS HERE
BEGIN WordPress
Let me know if that works!
-
Got one.
This is the content - not certain that's what I need?
redirect permanent /index.html http://www.global-lingo.com/index.php
BEGIN WordPress
<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</ifmodule>END WordPress
-
Ah, I see what you are saying. You want to download the one from the site root for redirects. Typically, that is going to be something like a /public_html or /httpdocs folder. Do you have an htaccess file there?
-
That's what I want to do. But I can't be sure I have the right file. There are .htaccess files in a few folders
Thanks for bearing with me Matthew
-
Hey -
Glad you got everything in the right format!
Can you download your current .htaccess file via FTP? I'd download that and then add the new redirects at the bottom of the file and then upload the file. Be sure to save a backup of the htaccess file before you make changes.
Let me know if that works? Thanks,
Matthew -
Ok now I'm stuck again!
I have the list, in the right format, thanks to Matthew.
I can see where to upload the file, but now I'm worried that it will replace all my existing redirects. From the WordPress site I can't see where I can export all the existing redirects so that I could at least add my new ones to the existing ones and upload a new file.
Any ideas guys?
-
Brilliant, thanks Matthew
-
Hey Richard,
You are really close! In column A, do a find for "http://www.global-lingo.com" and replace with nothing. That way you are left with:
A = /news/2009/12/news-internet-translations/
B = http://www.global-lingo.com/blog/
C = redirect 301 /news/2009/12/news-internet-translations/ http://www.global-lingo.com/blog/
Thanks,
Matthew -
Hi Matthew,
Sorry, pretty nervous now!
Here's what I have in the columns
A = http://www.global-lingo.com/news/2009/12/news-internet-translations/
B = http://www.global-lingo.com/blog/
C = redirect 301 http://www.global-lingo.com/news/2009/12/news-internet-translations/ http://www.global-lingo.com/blog/
I think I got a little lost with the full URL in column A. What should I remove? Or have a got it correct? Sorry to use the real URL I just want to make sure I get this correct.
Thanks
Richard
-
Hi Matthew,
That is the perfect answer, thank you so much. Just creating the file was where I was getting stuck and knowing what to put in the columns.
what I have at the moment is:
Column A = 404 url
Column B = URL I want
That solution is perfect, I'm more than happy using that!
-
Hi Richard,
Updating htaccess files can be tricky, especially with that risk of wrecking your site if you do something wrong. So, not a dumb question at all.
WordPress is a great way to add redirects, but if you are dealing with hundreds that can equal a lot of time.
So, if you are looking for a way to quickly build the htaccess file vs. doing everything manually in WordPress, my trick is use to a concatenation function in Excel. That way I can write hundreds of redirects at once and then copy the resulting text into the htaccess file.
The general idea is you have your old URL path in col A, the new URL (full URL) in column B, and then in column C, you'd have a formula that looks something like this (obviously line numbers might change):
="redirect 301 " & A2 & " " & B2
You could then copy column C and add that to your .htaccess file. Of course, back up the htacecss file first. The only word of caution would be to make sure you have valid paths in column A (no special characters, no full URLs, etc.).
Hope that helps.
-
Hi Tom,
Thanks for the quick response. That's why I'm being very careful. I have used the re-direction tool but as there are quite a lot to do I was looking for some way to create one big file and then upload rather than copy and paste nearly 300 entries
-
Hey Richard
This isn't a thick question at all - you're very wise to take care with this. A faulty .htaccess file can cause chaos!
Just wanted to make a suggestion - if you're running WordPress have you tried the Redirection plugin? It does all of the rewriting for you - just pop in the old URL and the new URL and you're on your way. Comes with a few other features too and has had tons of downloads over the years.
If you want to go down the route of self-education, check out the SEOMoz redirection guide and also this blog post on some useful .htaccess snippets.
I'd recommend using the redirection plugin for 2-3 urls, check it works then look at the generated .htaccess file in your website's backend. From there, you can see the correct format and filetype etc. If the tool works, just continue to use it.
Hope this helps!
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
6 .htaccess Rewrites: Remove index.html, Remove .html, Force non-www, Force Trailing Slash
i've to give some information about my website Environment 1. i have static webpage in the root. 2. Wordpress installed in sub-dictionary www.domain.com/blog/ 3. I have two .htaccess , one in the root and one in the wordpress
Intermediate & Advanced SEO | | NeatIT
folder. i want to www to non on all URLs Remove index.html from url Remove all .html extension / Re-direct 301 to url
without .html extension Add trailing slash to the static webpages / Re-direct 301 from non-trailing slash Force trailing slash to the Wordpress Webpages / Re-direct 301 from non-trailing slash Some examples domain.tld/index.html >> domain.tld/ domain.tld/file.html >> domain.tld/file/ domain.tld/file.html/ >> domain.tld/file/ domain.tld/wordpress/post-name >> domain.tld/wordpress/post-name/ My code in ROOT htaccess is <ifmodule mod_rewrite.c="">Options +FollowSymLinks -MultiViews RewriteEngine On
RewriteBase / #removing trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L] #www to non
RewriteCond %{HTTP_HOST} ^www.(([a-z0-9_]+.)?domain.com)$ [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L] #html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [NC,L] #index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
RewriteRule ^index.html$ http://domain.com/ [R=301,L]
RewriteCond %{THE_REQUEST} .html
RewriteRule ^(.*).html$ /$1 [R=301,L]</ifmodule> The above code do 1. redirect www to non-www
2. Remove trailing slash at the end (if exists)
3. Remove index.html
4. Remove all .html
5. Redirect 301 to filename but doesn't add trailing slash at the end0 -
Htaccess Question - Is this the way to go to consolidate?
Hi all, My site seems to have www.xyz.com, http://www.xyz.com, http://xyz.com and other variations! From an old agency doing this. All showing differing backlinks etc. SO I want to merge them so I can just look at one analytics account - with everything combined. I want it just to consolidate all to https:///www.xym.com as the client wants - how do I do this? Does it take long to take effect?? Also I presume in webmaster I'll have to set up the preferred extension? Thanks very much for any advice 🙂
Intermediate & Advanced SEO | | VMLQais0 -
Redirects in .htaccess file
I am using yoast seo plugin for wordpress. I have done several link changes and placed approximately 80-100 301 redirect into .htaccsses file. Is this good practice? Do they have to be there forever? Is it not slowing down site? Or should this be done in different way? Thank you very much Iris
Intermediate & Advanced SEO | | Rebeca10 -
Help with htaccess
I just setup a WP install in a subfolder: domain.com/development/ However, there is an existing htaccess file in the root which contains the following: RewriteRule ^([A-Za-z_0-9-]+)$ /index.php?page=$1 [QSA]
Intermediate & Advanced SEO | | SCW
RewriteRule ^([A-Za-z_0-9-]+)/$ /index.php?page=$1 [QSA]
RewriteRule ^([A-Za-z_0-9-]+)/([a-z]+)$ /index.php?page=$1&comp=$2 [QSA]
RewriteRule ^([A-Za-z_0-9-]+)/([a-z]+)/$ /index.php?page=$1&comp=$2 [QSA] I need to leave the rules as-is due to the nature of CMS (not WP) under the root domain. Is it possible to include an exception or condition which allows URL requests containing /development/ to resolve to that folder? I tried to add: RewriteRule ^development/([A-Za-z_0-9-]+)$ /development/index.php?page=$1 [QSA] but this seems to send it in a loop back to the root. Thanks!!!0 -
.htaccess files
I am working with a clients website which has multiple htaccess files (.htaccess , .htaccess.holiding, and .htaccess.live -all in the same directory) My question is how does a server process these files? All 3 files? Currently the domain has 301 redirect showing for the home page to the mobile site (which is a problem) in one of the files (.htaccess but not others) Has anyone come across this before with regard to SEO problems?
Intermediate & Advanced SEO | | OnlineAssetPartners0 -
301 redirect via htaccess question
So, I have www.sitea.com and www.siteb.com I want to redirect SOME pages from www.sitea.com to www.siteb.com (example: www.sitea.com/plugins/wp/ to www.siteb/wp/ etc ) and the rest of any pages left, to the homepage of www.siteb.com. It is something with conditions... any help, please?
Intermediate & Advanced SEO | | jasmin280 -
Newbie to SEO and SEOMOZ help
Hey everyone i just came across SEOMOZ today, i have been building websites for 3 years now but SEO is something which has always been a scary topic to consider trying to master. I have made a decision to do this in 2012 and i have been looking for a software package which can stear me and teach me. I have been reading the site help today and i feel totally swamped! i have created my campaign but a lot of the results dont make much sense to me and i am unsure of how to fix the errors they found. For instance the crawl diagnostics shows i have 5 4xx client errors. They show me a link to the page where the error is http://www.mydomain.com/category/latest-news/function.require but when i go to see what this is i just find an error 404 not found page.How do i go about removing this error if i have no idea where the problem is? I have started reading SEO User guide and beginers guide and i know it is going to take me a long time to get use to this all, but i am struggling to find the starting point and hope someone can possible help me find the first few steps. Thanks
Intermediate & Advanced SEO | | buntrosgali0 -
What are the best strategies to organize a htaccess full of 301 re-directs
I have a client with a htaccess file that is a total mess! What are the best practices to organize all the re-directs, and make it more manageable in the future. Any resources would be appreciated.
Intermediate & Advanced SEO | | anchorwave0