• Home
  • Download
  • Links
  • Photoplog
  • Blowfish Secret
  • Base64
  • Wordpress Salt
  • Contact
  • ROM
  • Skins
  • VIP
  • Tutorial
Wckediden - Mobile Tricks and Tweaks Community  

Go Back   Wckediden - Mobile Tricks and Tweaks Community > Community Software > Webmaster Software (Windows System Only 64bit) > Apache Server
Reload this Page [INFO] Guide to 301 Redirects with an .htaccess File
Wckediden
Register Forum Rules FAQ Community Today's Posts Search

Notices
Under Construction

WckedIDen Forum Renovations

WckedIDen is currently undergoing forum structure renovations. During this process, you may experience intermittent errors, unavailable pages, or temporary service interruptions.

Please be patient while we work to improve the forum. We appreciate your understanding and continued support.


Community Links
Social Groups
Pictures & Albums
Members List
Meet Our Staff
Search Forums
 
Tag Search
Advanced Search
Search Downloads
Advanced Search
Search Links
Advanced Search
Find All Thanked Posts



Post New ThreadReply
 
Thread Tools Search this Thread
  #1  
Old 07-13-2024, 01:27 AM
wcked's Avatar
wcked wcked is offline   Thread Starter  
Supporter/Designer
Mobile Model: Google Pixel 10 Pro
Mobile Carrier: Metro PCS
Mobile OS: Android

  usa
 
Join Date: November 8th, 2005
Location: North Philadelphia
Posts: 10,398
Downloads: 18
Uploads: 181
wcked has disabled reputation


View wcked's Profile   Edit Options Edit Profile Picture View wcked's Photo Album Add wcked's to Your Contacts Show Groups Edit Avatar Subscribed Threads Private Messages
Default Guide to 301 Redirects with an .htaccess File

A 301 redirect using an .htaccess file is a redirect that you create when you rewrite a piece of code on your site.

There are many reasons why you might want to input a 301 redirect on your site, but how do you do it, and why should you do it the .htaccess way? WeÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ ’¢â€šÃ⠀šÃ‚¬ÃƒÂ¢Ã¢â†¬Å¾Ã‚¢ve got the answers.

But before we go into specifics, letÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢s dive into 301 redirects.

[HEADING=1]What Is a 301 Redirect?[/HEADING]
A 301 redirect is a permanent redirect. When a user tries to access an old URL, the server sends their browser the 301-Permanently Moved status code and sends them to another page. This is useful for site owners and users because it means they are directed to the next most relevant page.

301 redirects are useful for search engines too because they help to keep their indexes updated. They inform search engines that content has been moved and ensure that the visibility associated with the original page is transferred to the new URL.

For more information, take a look at our comprehensive SEO guide to 301 redirects.

[HEADING=1]What Is an .htaccess File?[/HEADING]
An .htaccess file is a part of what controls the high-level configuration of your website. You edit the contents of your .htaccess file to enable and disable certain features of your server software without editing in the server configuration file directly. ItÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ ’¢â€šÃ⠀šÃ‚¬ÃƒÂ¢Ã¢â†¬Å¾Ã‚¢s a pretty easy way to make important changes, but you have to be really careful that youÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢re editing the code correctly. One mistake in your code can cause a lot of problems for users.

This means that a 301 redirect using an .htaccess file is a permanent redirect implemented via your .htaccess file rather than the server configuration file.

[HEADING=2]When Should You Use a 301 Redirect with an .htaccess File?[/HEADING]
A 301 redirect using an .htaccess file can generally be used in three different scenarios:
  1. To redirect visitors after youÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢ve moved to a new domain
  2. To redirect visitors after youÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢ve moved old site pages to a new site structure
  3. To redirect visitors to new pages after youÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢ve combined two sites

ItÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ ’¢â€šÃ⠀šÃ‚¬ÃƒÂ¢Ã¢â†¬Å¾Ã‚¢s pretty easy to do. WeÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ ’¢â€šÃ⠀šÃ‚¬ÃƒÂ¢Ã¢â†¬Å¾Ã‚¢ll walk you through how it works.

[HEADING=1]How to Do a 301 Redirect with an .htaccess File[/HEADING]
A 301 redirect is executed differently depending on the server you use. The .htaccess method is usually used on Apache servers but can be implemented on other servers too.

[HEADING=2]How to Do 301 Redirects with .htaccess Files on Apache[/HEADING]
Before you do anything, you need to locate the RewriteEngine, which you can find in the mod_rewrite module in Apache. You can load it using the following code:

<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
Then you can add all your rules below ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“RewriteEngine OnÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ ’¢â€šÃ⠀šÃ‚¬Ãƒâ€šÃ‚ ‚. The rules you add depend on what exactly you want to redirect.

[HEADING=3]Redirecting a Single URL[/HEADING]
When redirecting a single URL, all you have to do is add this code (make sure you substitute ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“oldpageÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚ and ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“newpageÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚ for your page names!):

RedirectMatch 301 /oldpage/ /newpage/
[HEADING=3]Redirecting a Single Folder[/HEADING]
When redirecting a single folder to a new location, you would use the following:

RewriteRule ^/?folder/(.\*)$ /location/$1 [R,L]
WeÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ ’¢â€šÃ⠀šÃ‚¬ÃƒÂ¢Ã¢â†¬Å¾Ã‚¢ve used ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“folderÃÃ*’ ƒâ€šÃ‚¢ÃƒÂ¢Ã¢â €šÂ¬Ã…¡Ã‚¬Ãà ¢â‚¬Å¡Ãƒâ€šÃ‚ and ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“locationÃÃ*†Ã‚Â¢ÃƒÂ¢Ã¢à ‚¬Å¡Ã‚¬Ã ‚ as our examples. Substitute your folder and location names!

[HEADING=3]Redirecting www to Non-www with a 301 .htaccess Redirect[/HEADING]
Maybe you want to run a redirect because you donÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢t want to use a www subdomain. If this is the case, youÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢ll need to redirect to a non-www version. HereÃÃ*’¢Ã ƒÂ¢Ã¢â‚¬Å¡Ã ‚¬Ã¢ââ⠚¬Å¾Ã‚¢s what you need; just replace ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“exampleÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚ with your own domain:

RewriteCond %{HTTP_HOST} ^(.\*)$ http://example.com/$1 [L,R=301]
[HEADING=2]How to Do 301 Redirect with .htaccess Files on WordPress[/HEADING]
Firstly, youÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢ll have to connect your siteÃÃ*’¢Ã ƒÂ¢Ã¢â‚¬Å¡Ã ‚¬Ã¢ââ⠚¬Å¾Ã‚¢s server to edit your .htaccess file. To do this, you have two options.
  1. Connect to your server through FTP
  2. Use the built-in File Manager tool, which you can find in cPanel

To use the built-in File Manager tool, log in to your cPanel dashboard and locate the tool. Then back up your .htaccess content and use the Edit function to add your 301 redirect code. This will take you to the text editor. From here, you can add the code you need.

Of course, the 301 redirect code you need depends on what you want to achieve.

[HEADING=3]Redirecting a Single Page[/HEADING]
To redirect a single page to another one, youÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢ll need to add the following code, replacing ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“oldpageÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚, ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“exampleÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚, and ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“newpageÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚ with your details:

Redirect 301 /oldpage.html http://www.example.com/newpage.html
[HEADING=3]Redirecting a Domain Name [/HEADING]
To redirect an entire domain name to another domain name, use the following code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)oldsite\.com$ [NC]
RewriteRule ^http://newsite.com%{REQUEST_URI} [L,R=301]
Just, as always, make sure that you put in your information instead of ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“oldsiteÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚ and ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“newsiteÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚.

[HEADING=2]How to Do 301 Redirects with .htaccess Files in Windows[/HEADING]
If you use Windows to run your site, weÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ ’¢â€šÃ⠀šÃ‚¬ÃƒÂ¢Ã¢â†¬Å¾Ã‚¢ve also got you covered.

[HEADING=3]Redirecting a Single Page[/HEADING]
To redirect a single page, type in the page name under the Pattern field. Your code might look something like this, with your details subbed in:

blog/page-name/
[HEADING=3]Redirecting an Entire Website[/HEADING]
Redirecting your entire site to another domain is also super easy. You just need to add the following to your .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newsite.com/$1 [R=301,L]
And replace ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“newsiteÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚ with your domain name!

For more information, check out our article on the 16 crucial SEO steps when redirecting an entire website.

[HEADING=3]Redirecting Old URLs to New URLs[/HEADING]
If you change your filenames for specific pages, you can redirect to the new URLs by inputting the following code and replacing ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“oldpageÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚, ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“exampleÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚, and ÃÃ*â€™Ãƒâ€šÃ‚Â¢ÃƒÆ Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã…Â¡Ãƒâ šÃ‚Â¬ÃƒÆ’Ã¢â‚¬Â¦ÃƒÂ¢Ã¢â €šÂ¬Ã…“newpageÃÃ*’ ¢âââ ‚¬Å¡Ã‚¬Ã ¢â‚¬Å¡Ãƒâ€šÃ‚ with your info:

redirect 301 /oldpage.html http://www.example.com/abc/newpage.html
[HEADING=1]How to Identify & Fix Redirect Issues[/HEADING]
SEO issues arenÃÃ*’¢Ã ƒÂ¢Ã¢â‚¬Å¡Ã ‚¬Ã¢ââ⠚¬Å¾Ã‚¢t foreign to any of us, and, like any other feature, redirects can cause problems too.

With our Site Audit tool, you can quickly recognize and resolve any problems you might have with your redirects.

The Site Audit tool can recognize problems like:
  • No redirect or canonical to HTTPS homepage from HTTP version
  • Redirect chains and loops
  • Pages with temporary redirects
  • Pages with a broken canonical link
  • Broken external links
  • Broken internal links

So, if youÃÃ*’¢Ã ’¢â€šÃ €šÃ‚¬ÃƒÂ¢Ã¢â†šÂ¬Ã…¾Ã‚¢ve just added some redirects to your site, hereÃÃ*’¢Ã ƒÂ¢Ã¢â‚¬Å¡Ã ‚¬Ã¢ââ⠚¬Å¾Ã‚¢s how to set up your Site Audit to find any technical issues and get them resolved.ÃÃ*’Ã‚Â ÃƒÂ¢Ã¢â‚¬Å Ã‚Â¬ÃƒÂ¢Ã¢à €šÂ¬Ã‚¹

Reply With Quote
wcked
View Public Profile
Visit wcked's homepage!
Find all posts by wcked
Post New ThreadReply

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Thread Tools
Show Printable Version Show Printable Version
Search this Thread

Advanced Search
Donate Via PayPal
Amount:
Enter Short Message:
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
[INFO] Apache MIME for httpd.conf or .htaccess wcked Other Server Software 0 07-13-2024 01:45 AM
[INFO] Redirect Old Domain to New Domain via .htaccess wcked Apache Server 0 07-13-2024 01:24 AM
Hi from 301-262-8404 301-262-8404 Member Introductions 1 12-27-2007 01:30 PM


All times are GMT -4. The time now is 08:37 AM.

Wckediden Community - Archive - Privacy Statement - Terms of Service - Top


Powered by vBulletin® Version 3.8.14
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Template-Modifications by TMS
POWERED BY PHILLYFINESTSERVERSTAT FOR WCKEDIDEN|- NEXTELELITE| - PPCTHEME| - IDENINSIDER