Redirect Rule Generator

Paste your old and new URLs, then export 301 or 302 rules for Apache, Nginx, PHP, or JavaScript.

Generate Redirects

Enter your source URLs and destination URLs (one per line). The tool will automatically pair them and generate redirect rules in your chosen format.

Understanding Export Formats

Each export format serves different server configurations and use cases. Choose the format that matches your server environment.

Apache (.htaccess)

What is Apache .htaccess?

Apache .htaccess is a configuration file used by Apache web servers to control directory-level server behavior. It allows you to implement URL redirects, rewrites, access controls, and other configurations without modifying the main server configuration file.

When should I use Apache redirects?

Use Apache .htaccess redirects when:

  • Your website runs on an Apache web server
  • You have access to .htaccess files in your hosting
  • You're using shared hosting (most use Apache)
  • You want server-level redirects that work before page rendering
  • You need to implement 301, 302, or 307 redirects for SEO

How to implement Apache redirects?

  1. Download the generated .htaccess file
  2. Upload it to your website's root directory (or the relevant subdirectory)
  3. If an .htaccess file already exists, append the redirect rules to the existing file
  4. Test the redirects using a browser or redirect checker tool
  5. Monitor your server logs to ensure redirects work correctly

Nginx Configuration

What is Nginx configuration?

Nginx (pronounced "engine-x") is a high-performance web server and reverse proxy. Nginx configuration files contain server directives including redirect and rewrite rules. Unlike Apache, Nginx doesn't support directory-level configuration files, so all redirects must be added to the main configuration.

When should I use Nginx redirects?

Use Nginx configuration redirects when:

  • Your website runs on an Nginx web server
  • You have access to Nginx configuration files (VPS or dedicated server)
  • You need high-performance redirects for high-traffic websites
  • You're running a modern web stack (Nginx is faster than Apache for static content)
  • You want to leverage Nginx's efficient regex-based routing

How to implement Nginx redirects?

  1. Download the generated Nginx configuration file
  2. SSH into your server and locate your Nginx config (usually /etc/nginx/sites-available/your-site)
  3. Add the redirect rules inside your server block
  4. Test the configuration: nginx -t
  5. Reload Nginx: sudo systemctl reload nginx
  6. Verify redirects are working correctly

PHP Script

What is PHP redirect script?

PHP redirect scripts use server-side PHP code to check the current URL and redirect users to the correct destination. The script creates an associative array mapping old URLs to new URLs and uses PHP's header() function to send 301 redirect responses.

When should I use PHP redirects?

Use PHP redirect scripts when:

  • You don't have access to .htaccess or Nginx configuration
  • Your site is built with PHP (WordPress, Laravel, custom PHP)
  • You want application-level redirects with custom logic
  • You need conditional redirects based on user data or cookies
  • You're on shared hosting with limited server configuration access

How to implement PHP redirects?

  1. Download the generated PHP redirect script
  2. Include the script at the top of your site's main PHP file (index.php or header.php)
  3. For WordPress: Add to functions.php or create a custom plugin
  4. Ensure the script runs before any HTML output
  5. Test redirects in a browser and verify 301 status codes

JavaScript Client-Side Redirects

What are JavaScript redirects?

JavaScript redirects use client-side code (runs in the browser) to check the current page URL and redirect users to the correct destination. The script uses window.location.href to perform the redirect after the page loads.

When should I use JavaScript redirects?

Use JavaScript redirects when:

  • You have no server-side access (static hosting like GitHub Pages, Netlify)
  • You're building a single-page application (SPA)
  • You want client-side routing in React, Vue, or Angular apps
  • You need conditional redirects based on browser features or screen size

SEO Warning: JavaScript redirects are NOT recommended for SEO purposes. Search engines may not follow client-side redirects correctly, and they don't pass PageRank like server-side 301 redirects. Use server-side redirects (Apache, Nginx, PHP) for SEO migrations.

How to implement JavaScript redirects?

  1. Download the generated JavaScript file
  2. Include it in your HTML: <script src="redirects.js"></script>
  3. Place the script tag in the <head> section for faster execution
  4. Test in different browsers to ensure compatibility
  5. Monitor analytics to track redirect behavior

CSV (Comma-Separated Values)

What is CSV export?

CSV export creates a spreadsheet-compatible file with columns for source URLs and destination URLs. This format is ideal for documentation, planning, review, and importing into redirect management tools or plugins.

When should I use CSV export?

Use CSV export when:

  • You need to review redirects in Excel or Google Sheets before implementation
  • You're using a redirect plugin (Redirection for WordPress, etc.)
  • You want to share redirect mappings with clients or team members
  • You need to import redirects into a CMS or redirect management platform
  • You're documenting your site migration for future reference

How to use CSV exports?

  1. Download the CSV file
  2. Open in Excel, Google Sheets, or any spreadsheet software
  3. Review the redirect mappings and make any necessary edits
  4. Import into your redirect plugin (most support CSV import)
  5. For WordPress: Use Redirection plugin's CSV import feature
  6. For Shopify: Use the built-in URL redirect CSV importer

YAML Configuration

What is YAML redirect configuration?

YAML (YAML Ain't Markup Language) is a human-readable data serialization format commonly used for configuration files. YAML redirect configurations are used by modern static site generators (Netlify, Vercel), headless CMS platforms, and containerized applications.

When should I use YAML redirects?

Use YAML redirect configuration when:

  • You're using Netlify, Vercel, or Cloudflare Pages
  • Your site is built with static site generators (Next.js, Gatsby, Hugo)
  • You're using JAMstack architecture
  • You need configuration-as-code for version control and deployment
  • You're working with modern serverless platforms
  • You want redirects deployed automatically with CI/CD pipelines

How to implement YAML redirects?

  1. Download the generated YAML file
  2. For Netlify: Add to _redirects file or netlify.toml
  3. For Vercel: Add to vercel.json configuration
  4. For Cloudflare Pages: Add to _redirects file
  5. Commit the configuration to your Git repository
  6. Deploy your site - redirects will be automatically configured
  7. Test redirects using your platform's preview deployments

Redirect Best Practices

Always Use 301 Redirects for Permanent Changes

301 (Moved Permanently) redirects tell search engines that a page has permanently moved to a new location. This transfers link equity (PageRank) from the old URL to the new URL, preserving your SEO rankings.

Test Before Going Live

Always test redirects on a staging environment before implementing them on your live site. Use browser developer tools or redirect checker tools to verify that redirects return the correct status codes (301 or 302) and destination URLs.

Avoid Redirect Chains

Redirect chains (A → B → C) slow down page load times and dilute link equity. Always redirect directly from the old URL to the final destination URL. If you discover redirect chains, consolidate them into single-hop redirects.

Monitor 404 Errors

After implementing redirects, monitor your server logs and Google Search Console for 404 errors. Any remaining 404s indicate missing redirects that need to be added.

Keep a Redirect Map

Download the CSV export and store it as documentation. This redirect map is valuable for future site migrations, troubleshooting, or explaining changes to stakeholders.