301 rdirect for custom URL - apache

I have a custom made image gallery site that I converted to WordPress, this site have few thousands link like this
http://www.example.net/Gallery?cmd=viewCarGallery&carID=13&pgID=1
http://www.example.net/Gallery?cmd=viewCarGallery&carID=9&pgID=1
All link is now converted to wordpress and now I am facing problem redirect them, I tried to using like this
Redirect 301 /Gallery?cmd=viewCarGallery&carID=9&pgID=1 http://www.example.net/gallery/gallery_ID
Please help me how can I redirect this kind of URL.

A permanent 301 redirect in your .htaccess file lets search engines and others know that an old link has been replaced by a new one. It's the recommended method for directing traffic from an existing page.I added below codes in my .htaccess file.
Redirect 301 /oldfile.htm /newfile.htm

I think what you need is mod rewrite. Take a look here http://www.askapache.com/htaccess/modrewrite-tips-tricks.html
It looks like a similar question https://superuser.com/questions/155139/htaccess-301-redirect-with-regular-expressions

Related

How to redirect an URL to another (.htacces)

Friends, I need to redirect an URL (which doen't exist in the blog anymore) to another one in the same blog. How could I do this with the help of .htaccess?
The problem is that we have a printed QR-Code which leads people to this old URL which was in our old blog. We have another one now, using the same subdomain. Any idea?
From
https://blog.mywebsite.com.br/2020/08/28/planner-para-que-serve-e-como-usar/
To
https://blog.mywebsite.com.br/planner-para-que-serve-e-como-usar/
I have tried this so far:
Redirect "https://blog.volarepaper.com.br/2020/08/28/planner-para-que-serve-e-como-usar/"
"https://blog.volarepaper.com.br/planner-para-que-serve-e-como-usar/"
and this as well:
Redirect "https://blog.volarepaper.com.br/2020/08/28/planner-para-que-serve-e-como-usar/"
"https://blog.volarepaper.com.br/planner-para-que-serve-e-como-usar/"
You can not use full URL in the pattern of Redirect . You can only use URL path :
Redirect 301 /2020/08/28/planner-para-que-serve-e-como-usar/ https://blog.volarepaper.com.br/planner-para-que-serve-e-como-usar/

guidelines for htaccess code to transition users to new website

Suppose I have an old website with 10 webpages, and I want to deprecate it and move visitors to a new website with 100 webpages.
Two of the webpages of the old website map directly to two corresponding webpages on the new website. All other pages on the old website should go to the new website's home page. How to set that up?
I know I can use .htaccess in the public_html folder of the old website to create some permanent redirect rules for individual pages. So for the two pages that need to map one-to-one, I can do:
Redirect 301 /oldfile1.htm http://www.example.net/newfile1.htm
Redirect 301 /def/oldfile2.htm http://www.example.net/123/456/newfile2.htm
But what about all the other webpages on the old website? This is where my knowledge of .htaccess lacks. Does the .htaccess stop executing when it reaches one of the redirects above? If so, then perhaps I simply place the following AFTER the above code to catch the remaining pages?
Redirect 301 / http://www.example.net/
Or, something else? Also, will the redirect directly above map all webpages it sees to the home page of the new website (I assume so), or a matching directory/webpage page on the new website? -- That is, I don't want the situation where http://www.olddomain.com/abc/Oldfile1234.html takes users to http://www.example.net/abc/Oldfile1234.html on the new website (rather, it should take users to http://www.example.net) since most webpages do not map one-to-one.
Lastly, in the .htaccess file on the old website public_html directory, how to account for users coming from https versus http, and www versus non-www URLs?
I'm hoping there's common strategy people use for this sort of thing, since it should be fairly common, so I don't have to re-invent one.
You should be using RedirectMatch for precise matching using regular expressions. You can place these rules in root .htaccess:
RedirectMatch 301 ^/oldfile1\.htm$ http://www.example.net/newfile1.htm
RedirectMatch 301 ^/def/oldfile2\.htm$ http://www.example.net/123/456/newfile2.htm
RedirectMatch 301 ^ http://www.example.net/

301 Redirect using .htaccess

I had a system migration on my website and approximately 400 links got permanently changed. I'm using the following Redirect in .htaccess file for redirecting old links to new links.
Redirect 301 /old-folder/old-product.html /new-folder/new-product.html
I'm planning to do the similar thing to all 400 links.
My problem: Since I'm all having these Redirect statements in one .htaccess file, will there be any performance issues? Is it okay to add so many Redirect statements in one .htaccess file? Are there any side effects?
Note: there is no fixed pattern in the old and new links so I can't use RewriteRule.

How to setup wild card 301 redirect that will remove URL parameters from index.php

ok I previously had some issues setting up a wild card redirect to strip parameters from an old url format that were non-seo friendly to our root. With the help of stackoverflow we've got it corrected and working but now I am experiencing issues with index.php?
Im seeing tons of duplicate urls in the engines using this url format index.php?cPath=# and Google is stressing me because they think its duplicate index pages.
I tried setting up this redirect in our htaccess but no go. It won't strip out the parameters or redirect it just duplicates the page with a valid 200 response.
RewriteRule ^index.php/.*$ /? [R=301,NE,NC,L]
I want to redirect anything with index.php?cPath=# to our root domain. Any ideas on how i can tackle this 301 redirect using a mod_rewrite on apache?
I've also just noticed that our site has another issue with this url format:
domain.com/?cPath=#...
so now I also need to write a rewrite for domain.com/?cPath=# I don't know where this one popped up from but I can see its going to cause issues hence the valid 200 response code it gives. The engines are really going to love me for this one.

Proper 301 redirect for sites

I have a bit of a complex question. I am moving sites from
http://www.hikingsanfrancisco.com
to
http://www.comehike.com
The directory structures will not be the same throughout both sites. What are some of the best practice things I can do in order to retain most of my existing SEO strength in both the general domain and individual pages for searches related to the other pages?
Thank you,
Alex
If most of the URLs are staying the same and just the domain is changing, you could create an .htaccess file in the root folder at the old site with the following:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.comehike.com/$1 [R=301,L]
This will make hikingsanfrancisco.com/some-page go to comehike.com/some-page.
Otherwise in that same htaccess file you could add a line for each redirect. So if hikingsanfrancisco.com/big-hikes is now going to comehike.com/even-bigger-hikes the redirect would look like:
Redirect 301 /big-hikes http://www.comehike.com/even-bigger-hikes
That 301 tells Google to now consider the new URL correct.
To redirect the whole site no matter what to the new URL you could use this:
Redirect 301 / http://www.comehike.com/
A 301 Redirect, page by page, is the best option (If you can use regular expressions is easier). Redirect the old page to a page in the new site with similar content.
Use the change of address tool in Google Webmasters tools.
Try to contact some of yours referrals to change the links that target your site.