.htaccess redirect from old to new - .htaccess

I have need to redirect (301) old url to new url. Here "XYZ" is a dynamic string variable. How can do this in apache2 ?.please help
old url is https://example.net/abc/XYZ/page?ref=XYZ-content and
new url is https://example.net/abc/XYZ/page/content

Related

How to add trailingshlash to redirect IF NOT already there in .htaccess (while pointing to new domain)

I migrated to a new domain so I would like all old url's point to the exact same page on the new url. Therefore I only have this code in my .htaccess file and this is doing what I would like it to do:
RewriteEngine on Redirect 301 / https://meditatieinstituut.nl/
But some old links with value does not have a trailing slash and the redirect to the trailing slash will only be made on the new domain. Therefore there is 1 more redirect than neccessary.
For example check this url in httpstatus.io:
http://www.vihara.nl/bewustwording/hoe-moet-je-mediteren-uitleg-vipassana-meditatie
So I would like:
http://www.vihara.nl/bewustwording/hoe-moet-je-mediteren-uitleg-vipassana-meditatie
NOT TO REDIRECT FIRST TO:
http://www.meditatieinstituut.nl/bewustwording/hoe-moet-je-mediteren-uitleg-vipassana-meditatie
BUT DIRECTLY TO:
http://www.meditatieinstituut.nl/bewustwording/hoe-moet-je-mediteren-uitleg-vipassana-meditatie/
So to redirect to the new domain WITH already with the trailing at the end.
But this should only be done if there is no trailingslash at the end.
Does anyone know how to do this?

URL redirection in htaccess

Current URL is
http://example.com/news/club/teamname
(Actual file is in this path only need to change URL)
I want to changed to
http://example.com/team/teamname
Using htaccess, its a wordpress site. I can't change the permalink.

.htaccess redirect old domain to new domain

I use from http://siteold.com/json/ in my application and can not change it.
and my new domain is http://panel.sitenew.com/json/ . how redirect my old url to new url without change in application ?
this way does not work (in siteold.com) :
RewriteEngine On
Redirect http://siteold.com/json/ http://http://panel.sitenew.com/json/
I don't think it is possible to redirect a URL to another URL. You will have to create a htaccess.txt file to the directory of the website you want to redirect, and then use this code
Redirect /siteold.com/json/ http://panel.sitenew.com/json/
This will redirect the old file path to the new file path. You cannot add http:// to the origin domain as the code doesn't work like that.
Source

Forcefully redirect to old url query string

Old url -> http://example.com/hotel/fortunep-park-grand/25
redirect new url via htaccess -
New Url http://example.com/property/fortunep-park-grand/25
Try :
RedirectMatch 301 ^/property/(.+)$ http://example.com/hotel/$1
This will 301 redirect changing the browser url from :
example.com/property/path
to
example.com/hotel/path
You can simply write Redirect [old_url] [new_url]:
RedirectMatch "^/hotel/(.*)" "http://example.com/property/$1"

Redirect Old URL to New URL open cart using htaccess

I want to redirect 301 old url to new url.
my old url is;
http://www.domainname.com/special
and new url is;
http://www.domainname.com/offers
I tried this code:
redirect 301 /http://www.domainname.com/special http://www.domainname.com/offers
But still now it's not redirecting & taking me to the old URL which does'nt exist.
Try this :
Redirect 301 /special /offers
Second argument of Redirect Directive is the URL Path, it doesn't start with Scheme and hostname.
There are various ways to do this and various redirects, I've listed them below:
301 (Permanent) Redirect: Point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the "example.com" domain:
This allows you to redirect your entire website to any other domain
Redirect 301 / http://example.com/
302 (Temporary) Redirect: Point an entire site to a different temporary URL. This is useful for SEO purposes when you have a temporary landing page and plan to switch back to your main landing page at a later date:
This allows you to redirect your entire website to any other domain
Redirect 302 / http://example.com/
Redirect index.html to a specific subfolder:
This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/
Redirect an old file to a new file path:
Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html
Redirect to a specific index page:
Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html

Resources