Wordpress page numbers and .htaccess ModRewrite rule - wordpress

we're getting quite a few errors popping up in webmaster tools. Our homepage paginated pages are showing up without the page prefix i.e. 17/ instead of page/17/
Can anyone help me write a rule to redirect these pages so the errors don't keep popping up?
We need to turn…
http://wwwexample.com/17/
into…
http://wwwexample.com/page/17/
We only need this to work for the homepage though as the pagination is working fine for the rest of the site i.e.
www.example.com/category/snails/17/ (This is working properly)
I'm not hot on mod rewrite and would like to start learning more about it.
Thanks,
James

Add these rules before your wordpress rules in your htaccess file in your document root:
RewriteRule ^([0-9]+)/$ /page/$1/ [R=301,L]

Related

.htaccess - Combatting String Query Spam, Custom 404 redirect

Been trying to clean up the aftermath of a decode64 content injection hack on multiple sites on my shared server.
It's clean, but now I'm getting links of incoming spam links with query string, like abc.com/?some-stupid-porno-spam/, so even though the content no longer exists, they're still being redirected to the front page. Am ranking for these spam words instead, or google's just saying those are soft-404s for the luckier sites.
Got a solution, but it's temporary. I was advised to add the following to the top of the .htaccess file:
RewriteEngine on
RewriteCond %{QUERY_STRING} .
RewriteRule ^/?$ - [L,R=404]
So, now all links with /? are redirected to a 404. 2 problems:
It's temporary, in that ALL /? queries are thrown to the 404, including wordpress post/page previews. Is there are way to make it such that it only works for non-existent pages?
The 404 points to the webhosts 404. How can I make it such that it goes to the theme's 404 instead?
Thanks for your time!
------ update
So, the above code works great. I can preview posts/pages, but I found there's a problem - it blocks wordpress' WYSIWYG text editor. The 'visual' tab remains blank, and none of the toolbars appear.
Help? lol

/blog (subdomain) 404 errors in webmaster tools /default.htm

I am new to Stackoverflow but a friend gave me a tip to ask my question over here since he couldn't help me as well. I have google's for multiple days now and I see that my rankings are dropping again in google because of all the crawl errors. My main site is build in serif webplus X5. I have added a wordpress blog to it which can be found at www.sitename .com/blog
Google has found more than 150 crawling errors and this is growing on a daily base, the point is that google ads behind all my blog url's /default.htm
I was wondering if someone can write me a htaccess 301 code for all these url's so it will instant redirect?
Today I started with manually redirecting some url's but this will not solve my problem because everytime I add another post and new tags all these new page's will also have the same default issue.
As you can imagine this is really frustrating grrr...
I have tried a lot of code's that I had found during my search but none of them did what I would like to achieve, other tips to get rid of the default page's are also very welcome.
Thank all of you who would like to fix this problem with me
Place this rule just below RewriteEngine On rule in main WP .htaccess:
RewriteCond %{THE_REQUEST} /default\.htm [NC]
RewriteRule ^(.*?)default\.htm$ /blog/$1 [L,R=301,NC,NE]

Removing index.htm from URL

I have a WordPress blog which is functioning just fine - the URLs are set to Month/Day/Year and everything on the front-end looks and functions fine.
However, when checking my stats and Google Webmaster Tools, there's tons of 404s that look like this:
http://theURL.com/normal-wordpress-url/index.htm
Of course, index.htm does not exist at the end of the WordPress URL, so the search engine is given a 404.
I have no idea what's causing this, as everything works fine for humans.
So basically, I need a way to tell search engines to forget about the index.htm at the end of the URL.
I've tried this in the .htacess with no luck:
RewriteCond %{REQUEST_URI} /index\.htm?$ [NC]
RewriteRule ^(.*)index\.htm?$ "/$1" [NC,R=301,NE,L]
Does anybody have any suggestions?
Maybe there are different problems in here that may need solution:
Problem 1: If the crawler is the one pointing to this page there are two things that you might need to do:
Try to go to Webmaster and delete "index.htm"
Try to create a robot that will disallow "index.htm" from being seen on Google Crawler.
Problem 2: If you have distributed your urls to point to this url, Google Webmaster can tell you which webpage it is coming from exactly.
So, try to make sure that all the links pointing to "index.htm" are removed from all other urls.

Trying to visit URL without www. causes WordPress to try and load the non-existent /defaultsite page

If I try to navigate to http://vequityintelligence.co.uk then WordPress redirects the browser (301 Moved Permanently) to http://www.vequityintelligence.co.uk/defaultsite which doesn't exist, so I get a 404 Not Found error.
The htaccess file is the one that came with WordPress.
I've refreshed my permalinks by changing the permalink format.
The site frontpage is set to the 'Recent Posts' option, but changing this doesn't affect it.
I understand why I get redirected, but I don't understand where the addition of '/defaultsite' comes from.
I have searched google and SO with very few results, let alone any answers. I can't think what else might cause this.
I imagine you don't need this answer anymore, but adding it for posterity: weird as it sounds, I think it's a caching issue.
I just came across this with a client's site I'm working on, and was at my wit's end, but then found some references that said it worked okay in one browser but not another, and clearing the cache fixed it.
An easy test: if you visit the URL in a browser you've never used to visit it, do you still have the issue? If not, it's probably just a matter of clearing the cache in the browser that is giving you trouble.
In the Wordpress dashboard > General Settings, check your setting for the Wordpress Address (URL) and Site Address (URL).
This is where I made sure the ‘www.’ was unnecessary for my URL.
I'd say it's a problem with the htaccess file. Perhaps adding the following code to htaccess will resolve the problem.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This redirects non-www to www. Put this near the top so it is processed before other rules are.
Code found here

/null being appended to Wordpress files, maybe via Shopp plugin

got a fairly wierd one that I can't replicate. I'm using the 'redirection' plugin in my wordpress setup, it is showing that almost 50% of the hits on the site are requesting urls with /null on the end - that results in a 404 error.
I'm using the Shopp plugin as well, and permalinks all round.
Has anyone experienced this?
Also, is there a way I can use .htaccess to say if there is /null on the end - then remove it?
Thanks!
No idea as to the source of this addition, but you can use .htaccess to get rid of it. Place this in your .htaccess after loading and enabling mod_rewrite and setting AllowOverride All:
RewriteRule ^(.*)/?null$ $1 [L,R=301,NC,QSA]

Resources