How to do redirect specific url to another url using htaccess file

301 Redirect Htaccess Rules

301 redirect rule

The .htaccess file or Hypertext Access file, is a configuration text file that controls the directory and any subdirectories located on an Apache webserver. 

How do redirect a single page to another url?

Redirect 301 /page.php http://www.urlname.com/page.html

How to do redirect an entire site or domain to another url?

Redirect 301 / http://www.urlname.com/

How to do redirect an entire site to a sub directory url ?

Redirect 301 / http://www.urlname.com/subfolder/

How to do redirect a sub directory to a another website?

Redirect 301 /subfolder http://www.urlname.com/

How to do redirect a file extension but retain the page name?

Example: If you want a .html extension to use the same filename but use the .php extension.
RedirectMatch 301 (.*)\.html$ http://www.urlname.com$1.php

How to do use rewriting to redirect from an old domain to a new domain?

RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.newurlname.com/$1 [R=301,L]

How to do use rewriting to redirect from a non-www to a www subdomain?

RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^urlname.com [nc]
rewriterule ^(.*)$ http://www.urlname.com/$1 [r=301,nc]

How to do use rewriting to redirect a domain to a www location with a subdirectory?

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} urlname.com [NC]
RewriteRule ^(.*)$ http://www.urlname.com/directory/index.html [R=301,NC]

How to do use rewriting to redirect from an old domain to a new domain that includes the full path and query string?

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) http://www.urlname.com%{REQUEST_URI} [R=302,NC]

How to do use rewriting to redirect from an old domain with a subdirectory to a new domain without the subdirectory but include the full path and query string?

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$
RewriteRule ^(.*) http://www.urlname.com/%1 [R=302,NC]

How to do rewrite and redirect URLs with query parameters with files placed in a root directory?

Example: The original URL being http://www.website.com/index.php?id=3 and the new URL being http://www.website.com/path-to-new-location/

RewriteEngine on

RewriteCond %{QUERY_STRING} id=3
RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301]

How to do redirect URLs with query parameters and place files in a subdirectory?

Example: The original URL being http://www.website.com/sub-dir/index.php?id=3 and the new page being http://www.website.com/path-to-new-location/

RewriteEngine on
RewriteCond %{QUERY_STRING} id=3
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301]

How to do redirect a site to HTTPS from HTTP to eliminate duplicate content?

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

How to do redirect a site from HTTP to HTTPS to eliminate duplicate content?

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

How to do remove an index.html or index.php and redirect to the root?

RewriteEngine On
RewriteCond %{THE_REQUEST} /index.php HTTP [NC]
RewriteRule (.*)index.php$ /$1 [R=301,L]
RewriteEngine On
RewriteCond %{THE_REQUEST} /index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]

How to do rewrite and redirect URLs with query parameters to a directory-based structure while retaining the query string in the URL root level?

Example: The original URL being http://www.website.com/index.php?id=100 and the new page being http://www.website.com/100/

RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]

How to do rewrite URLs with a query parameter to a directory-based structure while retaining query string parameters in the URL subdirectory?

Example: The original URL is http://www.website.com/index.php?category=fish and the new page being http://www.website.com/category/fish/

RewriteEngine On
RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA]

How to do redirect an old website to a new domain and retain the URL path?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^urlname-old\.com$ [NC]
RewriteRule ^(.*)$ http://www.urlname-new.com/$1 [R=301,L]
If you do not want to pass the path to the new domain, change the last line to:
RewriteRule ^(.*)$ http://www.urlname-new.com/ [R=301,L]

How to do rewrite and add a trailing slash to URLs without one?

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !(.*)/$ 
RewriteRule ^(.*)$ http://www.urlname.com/$1/ [R=301,L]

How to do redirect from a blog subdomain to a blog folder?

Example: Redirect blog.oldsite.com to www.newsite.com/blog/

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_URI}/ blog
RewriteRule ^(.*) http://www.surlname.com/%{REQUEST_URI} [R=302,NC]
RewriteRule ^(.*) http://www.urlname.com/blog/%{REQUEST_URI} [R=302,NC]

How to do redirect one directory to another?

Options +FollowSymLinks RewriteEngine On RewriteRule ^(.*)/old-directory/(.*)$ $1/new-directory/$2 [R,L]

Related Article

law assignment help

USA The Importance of the law assignment help services for students

Navigating the academic world for pursuing Law subjects, students have to engage in a lot of reading and writing. Whether it be school or college, assignment is an integral part of study. Law is a broad subject to study that includes a lot of…
environmental law assignment help

Get great academic grades with the help of environmental assignment services.

Environmental law involves preparing tasks based on a set of rules, regulations, and laws that govern human interaction with the environment. These laws protect the environment from human activities by relying on certain fundamental concepts.…
301 redirect rule

How to Make An Essay Lengthy For Better Assignment Help Online

Maybe you wish to understand how to make a paper lengthy because you've been researching and composing the essay without accomplishing the word or page count your instructor requires. Maybe you're becoming forlorn because you might not get this…
Law Assignment Help

Assignment Law: Everything You Need to Know

Introduction Assignments are an integral part of studying law. They help students develop critical thinking skills, analyze legal principles, and apply them to practical scenarios. However, assignments can be complex and challenging,…
Constitutional Law Assignment Help

Why is it so harder to understand constitutional law papers?

, ,
The Constitutional Law Assignment Help Experts at outline Constitutional Law as a hard and fast of regulations and rules that spell out the Powers and duties of various our bodies inside a rustic country. Constitutional Law additionally defines…
cm-feet-inches
thesis printing and binding online
headhunting_how-to-be
HUMAN RESOURCE CONSULTANT
How To Choose the Right Lawyer
notability of high school tuition