Htaccess रीडायरेक्ट जेनरेटर

.htaccess फ़ाइलों के लिए 301 रीडायरेक्ट कोड जेनरेट करें। अपने डोमेन के www से non-www या non-www से www वर्शन पर तुरंत रीडायरेक्ट करें।

i

Indexpro htaccess rewrite जेनरेटर टूल का उपयोग करके Htaccess के लिए www से non-www या non-www से www 301 रीडायरेक्ट कोड बनाएं। बस नीचे दिए 3 चरणों का पालन करें और "Get .htaccess Code" बटन पर क्लिक करें।

1. रीडायरेक्ट प्रकार चुनें

2. अपना डोमेन नाम दर्ज करें

www शामिल न करें। केवल डोमेन नाम - जैसे yourdomain.com

3. अपना कोड प्राप्त करें

आज की SEO टिप

प्रासंगिक उपकरण

.htaccess रीडायरेक्ट क्या है?

.htaccess रीडायरेक्ट एक सर्वर कॉन्फ़िगरेशन निर्देश है जो विज़िटर को स्वचालित रूप से एक URL से दूसरे URL पर भेजता है। .htaccess फ़ाइल Apache वेब सर्वर पर उपयोग की जाने वाली एक शक्तिशाली कॉन्फ़िगरेशन फ़ाइल है।

301 रीडायरेक्ट एक स्थायी रीडायरेक्ट है जो सर्च इंजन को बताता है कि पेज स्थायी रूप से नए स्थान पर चला गया है। यह सबसे SEO-अनुकूल रीडायरेक्ट प्रकार है क्योंकि यह लगभग 90-99% लिंक इक्विटी पास करता है।

www से non-www (या इसके विपरीत) रीडायरेक्ट SEO के लिए विशेष रूप से महत्वपूर्ण है क्योंकि सर्च इंजन www.example.com और example.com को दो अलग-अलग वेबसाइट मानते हैं।

.htaccess रीडायरेक्ट का उपयोग क्यों करें?

उचित .htaccess रीडायरेक्ट लागू करने से आपकी वेबसाइट के लिए कई फायदे मिलते हैं:

  • •SEO मूल्य एकत्रित करें – www और non-www वर्शन की रैंकिंग शक्ति को एक पसंदीदा डोमेन में संयोजित करें।
  • •डुप्लिकेट कंटेंट से बचें – सर्च इंजन को अलग URL वर्शन में आपकी साइट को डुप्लिकेट कंटेंट के रूप में देखने से रोकें।
  • •बेहतर एनालिटिक्स – सभी ट्रैफिक को एक जगह ट्रैक करें बजाय कई डोमेन वर्शन में बांटने के।
  • •पेशेवर स्वरूप – एक canonical URL फॉर्मेट का उपयोग करके अपनी ब्रांडिंग में स्थिरता बनाए रखें।
  • •बेहतर उपयोगकर्ता अनुभव – विज़िटर हमेशा एक ही URL फॉर्मेट देखते हैं, चाहे वे आपकी साइट को कैसे भी एक्सेस करें।
  • •लिंक इक्विटी संरक्षण – जब आपके पास डोमेन के अलग-अलग वर्शन की ओर इशारा करने वाले बैकलिंक हों तो बैकलिंक मूल्य बनाए रखें।
  • •सर्च इंजन वरीयता – सर्च इंजन को बताएं कि आप अपने डोमेन का कौन सा वर्शन इंडेक्स करना चाहते हैं।

जेनरेट किए गए कोड का उपयोग कैसे करें

  • 1..htaccess फ़ाइल ढूंढें – FTP के माध्यम से अपने सर्वर से कनेक्ट करें या होस्टिंग कंट्रोल पैनल के फ़ाइल मैनेजर का उपयोग करें। .htaccess फ़ाइल आमतौर पर रूट डायरेक्टरी (public_html या www फ़ोल्डर) में होती है।
  • 2.पहले बैकअप करें – कोई भी बदलाव करने से पहले, अपनी मौजूदा .htaccess फ़ाइल की एक कॉपी बैकअप के रूप में डाउनलोड करें।
  • 3.फ़ाइल संपादित करें – .htaccess फ़ाइल को टेक्स्ट एडिटर में खोलें। यदि फ़ाइल मौजूद नहीं है, तो ".htaccess" नाम की नई फ़ाइल बनाएं।
  • 4.कोड जोड़ें – जेनरेट किया गया कोड कॉपी करें और अपनी .htaccess फ़ाइल के शीर्ष पर पेस्ट करें।
  • 5.सहेजें और अपलोड करें – फ़ाइल सहेजें और यदि आपने इसे स्थानीय रूप से संपादित किया है तो सर्वर पर वापस अपलोड करें।
  • 6.रीडायरेक्ट टेस्ट करें – दोनों वर्शन (www और non-www) पर जाएं यह सुनिश्चित करने के लिए कि रीडायरेक्ट सही काम कर रहा है।
  • 7.त्रुटियां जांचें – यदि आपकी साइट अनुपलब्ध हो जाती है, तो बैकअप .htaccess फ़ाइल पुनर्स्थापित करें और कोड में टाइपो जांचें।

कोड को समझें

  • •RewriteEngine On – rewrite इंजन सक्रिय करता है, जो URL रीडायरेक्ट के लिए आवश्यक है।
  • •RewriteCond – एक शर्त निर्धारित करता है जो रीडायरेक्ट निष्पादित होने के लिए पूरी होनी चाहिए।
  • •%{HTTP_HOST} – URL में डोमेन नाम को संदर्भित करता है।
  • •[NC] – "No Case" के लिए है, अर्थात नियम case-insensitive है (WWW, www, Www आदि से मेल खाता है)।
  • •RewriteRule – वास्तविक रीडायरेक्ट नियम परिभाषित करता है।
  • •[L,R=301] – L का अर्थ है "Last" (आगे नियम प्रोसेस करना बंद करें), और R=301 स्थायी रीडायरेक्ट निर्दिष्ट करता है।

सर्वोत्तम प्रथाएं

  • •एक वर्शन चुनें – तय करें कि आप www या non-www पसंद करते हैं और सभी मार्केटिंग सामग्री में एक जैसा रखें।
  • •Google Search Console अपडेट करें – रीडायरेक्ट लागू करने के बाद Google Search Console में अपना पसंदीदा डोमेन वर्शन सेट करें।
  • •HTTPS उपयोग करें – यदि आपके पास SSL सर्टिफिकेट है, तो रीडायरेक्ट URLs में http:// की जगह https:// उपयोग करने के लिए कोड अपडेट करें।
  • •पूरी तरह टेस्ट करें – केवल होमपेज नहीं, अपनी साइट के विभिन्न पेज जांचें।
  • •ट्रैफिक मॉनिटर करें – रीडायरेक्ट लागू करने के बाद, अपने एनालिटिक्स मॉनिटर करें।
  • •बैकअप रखें – बदलाव करने से पहले हमेशा .htaccess फ़ाइल का बैकअप बनाए रखें।

Common Redirect Rules

Four rules cover the great majority of real redirect work. Each goes in the .htaccess file at your document root, inside an IfModule mod_rewrite.c block with RewriteEngine On above it.

Force HTTPS

Sends every http request to the https version of the same URL, preserving the path.

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Non-www to www

Picks one canonical host so the same page is not reachable at two addresses.

RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]

Redirect a single page

For a page that moved. Point it at the closest equivalent, not the homepage.

Redirect 301 /old-page https://www.example.com/new-page

Redirect a whole directory

Moves a folder and everything under it, keeping the rest of the path intact.

RewriteRule ^old-folder/(.*)$ /new-folder/$1 [L,R=301]

htaccess Questions, Answered

What is the difference between 301 and 302?

A 301 is permanent and tells Google to move the ranking signals to the new URL. A 302 is temporary and tells Google to keep the old one. Use 301 for anything that has genuinely moved. Using 302 by mistake is one of the most common ways sites lose rankings during a migration.

Do redirects pass link equity?

A 301 passes the great majority of it. What costs you is chaining: every extra hop adds latency and risk, and long chains can be abandoned by crawlers. Point the old URL at the final destination directly.

Where does the .htaccess file go?

In the document root of your site, usually alongside the homepage file. Rules in a subdirectory's .htaccess apply only to that directory and below.

Does .htaccess work on nginx?

No. It is an Apache feature. Nginx uses its own configuration syntax and ignores .htaccess entirely, so rules pasted there will silently do nothing.

Why did my redirect cause a loop?

Almost always a rule that matches its own destination, so the redirect fires again on arrival. Adding a condition that excludes the target URL, such as a RewriteCond checking the host or path, breaks the cycle.

Should I redirect deleted pages to the homepage?

Only if there is genuinely no closer match. Google treats mass redirects to the homepage as soft 404s, which means the old URL gets dropped anyway. A relevant page or a clean 410 is usually better.