1

Google is giving me a crawl error for pages that I have removed like www.mysite.com/mypage.html. I want to redirect this pages to the new page www.mysite.com/mysite/mypage. I tried to do that by using .htaccess but instead of fixing the problem, the crawl pages increased and a new crawl came www.mysite.com/www.mysite.com.

This is my .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sitename/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sitename/index.php [L]
</IfModule>
# END WordPress

Should I add this after the rewrite rule or I should do something else?

RewriteRule ^pagename\.html$ http://www.sitename.com/pagename [R=301]
1

Your problem may be to do with that rewritebase command.

Have you checked you redirects to see if they work properly?

I would place my custom redirects above the rewrite block of code. It makes more sense and avoids that rewritebase causing trouble. Just make sure you have a rewriteengine on before it all.

4
  • i tried it but under the rewrite code i will try to add it above it but i am afraid that the website may crash but you mean above all the rewrite rolls even the RewriteEngine On – sarah Mar 19 '13 at 5:42
  • i tried it before and after RewriteEngine On but nothing happened – sarah Mar 19 '13 at 5:48
  • RewriteEngine On should always be first. I was talking about the rewritebase command and it's effect on anything after it – Tony McCreath Mar 22 '13 at 15:40
  • 1
    The location of the RewriteBase directive makes no difference (it's not strictly processed top to bottom). The last RewriteBase directive (if there is more than one) controls the entire file, regardless of where it is placed. (The same as with the RewriteEngine directive for that matter.) However, the RewriteBase directive is not the issue in the code that the OP posted - its not actually being used, since there are no relative path substitutions in the OPs code. – MrWhite Feb 17 '19 at 22:27
0

I prefer to use the Redirect command in .htaccess rather than a rewrite rule for simple redirects:

redirect 301 /pagename.html http://www.sitename.com/pagename

But if you would rather use a rewrite rule, your rule looks like it should be fine.

When I run WordPress, it is more convenient for me to install the Quick Page/Post Redirect Plugin that allows me to specify all the redirects from the WordPress admin interface. I also install the True Google 404 Plugin that keeps track of 404s in the admin interface so I know which redirects to add.

4
  • thanks Stephen Ostermiller for replay i installed the plugin Quick Page/Post Redirect Plugin and redirected a page and opened the page to see if i is redirected or no but it still gives me 401 not found – sarah Mar 19 '13 at 5:38
  • Not found is 404, 401 is "not authorized". There is something else going on. – Stephen Ostermiller Mar 19 '13 at 9:31
  • what do you mean by something else ?? this is what appears Not Found The requested URL /servers.html was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Dimofinf Hosting mod_fcgid/2.3.6 Server at www.digitalways.com.sa Port 80 – sarah Mar 19 '13 at 12:18
  • You had said "401" not "404". Based on the ErrorDocument error message you just pasted in, you also have a problem similar to this one: serverfault.com/questions/299731/… – Stephen Ostermiller Mar 19 '13 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.