Redirect through htaccess

301 (Permanent) Redirect:

Use a 301 redirect .htaccess to 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.

When adding the following to your website’s .htaccess file, be sure to replace example.com with your own domain name.

# 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 directory to a new directory:

# Redirects example.com/old to example.com/new
RewriteRule ^old/(.*)$ /new/$1 [R=301,NC,L]

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

Redirect an error message:

Instead of prompting a 404 Not Found error page, the site will redirect to the homepage:

# Redirect 404 Error pages to the home page
ErrorDocument 404 http://example.com/

Redirect a non-existing page to index.php

# Redirect non-existing pages to index.php
Options +SymLinksIfOwnerMatch RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

Redirect 302 /genius https://drive.google.com/file/d/1bxSG8owlWIkhXSb0p_MOFqH-7_JhFumL/view

Redirect 302 /genuis https://drive.google.com/file/d/1iCqY-7KJvS8cnrFFabo6l3nVMGX5qWlG/view?usp=sharing

Redirect 302 /genuis /

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat