Google crawler mistakenly adds a wrong string of my domain to the end of every link in my site :(
For example: www.mydomain.com/folder/www.mydmain.com (as you can see the domain that adds to end of the link is not my original domain name).
it happens in many pages and what I thought to do is to create 301 redirect with
the correct URL removing the extra www.mydmain.com in the end of the URL.
I've tried several solutions that were offered here but with no success.
How can I remove the extra string at the end of the url in .htaccess?
Thanks!
Lior
You can use the following redirect in htaccess to remove the trailing part (www.domain.com) from your urls.
RedirectMatch 301 ^/(.+)/www\.domain\.com$ /$1/
Related
i replaced an old Joomla! Site with a new one and want to redirect selected old URLs to their appropriate new ones. The old Joomla! Site uses URLs like example.com/index.php/news or example.com/index.php/about and the new Site uses URLs like example.com/latest-news.html or example.com/about-us.html. Simple redirects using RedirectPermanent in .htaccess does not work (probably because the part after the slash is a query string, no URL segment). I searched the web but didn't found an answer.
Any suggestions?
Thanks in advance.
The following should work:
Redirect 301 /index.php/news http://example.com/latest-news.html
For query strings, did you look at similar post htaccess 301 redirect for URL with parameter
I originally asked a .htaccess question here and got some awesome help, which worked a treat. Basically, I'm trying to redirect pages from an old site to a new site, and have managed to make most things work. However, there's a couple of links in Google's search results that aren't redirecting properly, and I believe this is because they're all www and the new site redirects to non-www. For example, a link like this in the search engine results:
www.example.com/Expertise/ProductTesting
Should go to:
example.com/services/product-testing
But instead goes to:
example.com/services/ProductTesting
So for some reason the last part of the URL isn't changing. Here's how that line looks in my .htaccess:
RedirectMatch 301 ^/Expertise/ProductTesting/?$ /services/product-testing/
If I type the address in manually and drop the www, it redirects as it should.
Thanks in advance!
Taking your previous question into consideration, you must put your new rule before the one that is matching everything: RedirectMatch 301 ^/Expertise/(.*)$ /services/$1.
Also, you'll maybe have to clear your browser's cache before trying again (or try it with another browser).
Your rules should look like this
RedirectMatch 301 ^/Expertise/QuantitativeResearch/?$ /services/quantitative-research/
RedirectMatch 301 ^/Expertise/ProductTesting/?$ /services/product-testing/
RedirectMatch 301 ^/Expertise/(.*)$ /services/$1
I'm fairly new to htaccess, so if this is a noob question I apologize.
Recent I launched a newly designed website, and created 301 redirects for all of the old pages.
An example of one of the redirects is:
redirect 301 /about-busch-systems.html http://www.buschsystems.com/About/The-Busch-Company.php
The url:
"redirect 301 /about-busch-systems.html http://www.buschsystems.com/About/The-Busch-Company.php"
is in actuality:
"http://www.buschsystems.com/index.php?p=About&subPage=The-Busch-Company"
The redirect is sending me to the right page, with the proper URL, except the old page is being strung on the end as a variable.
Example:
redirect 301 /about-busch-systems.html http://www.buschsystems.com/About/The-Busch-Company.php
Sends me to "http://www.buschsystems.com/About/The-Busch-Company.php?p=about-busch-systems
Any ideas of why this is happening?
Thanks in advance!
Because that is what Redirect is supposed to do:
Then any request beginning with URL-Path will return a redirect request to the client at the location of the target URL. Additional path information beyond the matched URL-Path will be appended to the target URL.
Use RedirectMatch if you want more control.
Hey I'm just setting up a few 301 redirects but I can't work out how to do this particular function.
I have a ton of pages on my existing site e.g.
/products/23
/products/3
/products/57
/products/36
..etc
That I all want to point to one page on a new domain .e.g.
http://www.mynewdomain.com/store
I've tried a few RewriteRules with no success!
Thanks for any help !
It should work with a RedirectMatch directive (although you don't specify in your question how to pass the product codes to the new page):
RedirectMatch301 ^/products/(.*) http://www.mynewdomain.com/store/$1
This rule will redirect /products/NNN to http://www.mynewdomain.com/store/NNN (with HTTP status code 301).
I've searched, tried various examples, and none, other than creating an explicit list of redirect statements seems to work.
The biggest issue I have is that, although I have access to deploy web pages to the site, I do not have access to any web hosting control panel - site access was inherited, and until now it's been fine, but I think that it is either running an old version of apache, or rewrite rules are not allowed.
Anywa, over the years, the site has changed several times, and after registering the site with Google Webtools, I found the list of pages that gave crawl errors, so created an HTACCESS file to deal with these.
Over the years, there have been folders deployed and named in camel case and all lower case, and so all I wanted to do was to redirect all files in a folder to the new folder in the .htaccess file level, i.e.
My .HTACCESS currently has 120 lines, and an example batch are as follows:
redirect 301 /challenge/stanley_steamer.htm /lsr_history.html
redirect 301 /challenge/stanley_steamer.html /lsr_history.html
redirect 301 /Challenge/index.htm /lsr_history.html
redirect 301 /Challenge/Record.htm /lsr_history.html
redirect 301 /Challenge/Stanley_Steamer.htm /lsr_history.html
redirect 301 /Challenge/Sponsors/Avery_Weigh-Tronix.htm /sponsors.html
redirect 301 /contact/index.html /contact.html
redirect 301 /design/details.html /design.html
redirect 301 /design/index.html /design.html
redirect 301 /Design/Engine-drive_train.htm /design.html
redirect 301 /Design/Rear.htm /design.html
redirect 301 /Design/Home_Page.htm /design.html
redirect 301 /Design/index.htm /design.html
As you can see, I have some cases where the folder name is camel, others lower, and other cases where there is a htm and an html file of the same name that is listed in the crawl error log.
All I want to do is, in the example above, redirect all pages from /Challenge/ and /challenge/ to lsr_history.html, but all files in /Challenge/Sponsors/ to sponsors.html.
I also have a huge list of individual team pages that I list one by one and each one redirects to the new team page.
I've tried examples like:
RedirectMatch 301 ^/[Cc]hallenge/ /challenge.html, but this returns a 'Error 404 Not found'.
Any ideas or examples of how I can cut down my htaccess file to simplify this will be gratefully received.
Regards
Martin
I wouldn't bother searching for cases inside the match string for this kind of thing if I could avoid it - have you tried just specifying the RedirectMatch in lowercase, and appending [NC] to the end of every line? (that will tell mod_rewrite to ignore case and match regardless, which may save you some time)
if you have collections of similarly-formatted rewrites, why not group them together with one particular set of rules for each? That way you could cover, for example, all incoming URLs with one subdirectory with one rule, and all incoming URLs with a single subdirectory one with another rule. If nothing else, it could help simplify viewing the .htaccess file :)
(Take everything I suggest with a massive dose of salt, I'm still getting to grips with the black magick of mod_rewrite myself)