Skip to content

lukechilds/htconvert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

htconvert

Convert .htaccess redirects to nginx.conf redirects.

Build Status Coverage Status npm npm

Install

npm install --global htconvert

Usage

$ cat .htaccess | htconvert > nginxRedirects.conf
# or
$ htconvert -f .htaccess > nginxRedirects.conf

.htaccess

# Frontend Redirects
Redirect 301 /deleted-page/ https://website.com/new-page/
Redirect 302 /new-feature/ https://website.com/coming-soon/

# Admin Redirects
Redirect 301 /admin/ https://website.com/?login=true

nginxRedirects.conf

# Frontend Redirects
location /deleted-page/ {
  return 301 https://website.com/new-page/;
}
location /new-feature/ {
  return 302 https://website.com/coming-soon/;
}

# Admin Redirects
location /admin/ {
  return 301 https://website.com/?login=true;
}

Options

$ htconvert --help

  Usage: htconvert [options]

  Options:

    -h, --help              output usage information
    -V, --version           output the version number
    -f, --file [.htaccess]  File containing .htaccess redirects

Node

This is also usable as a node module

npm install --save htconvert
var htconvert = require('htconvert');
var htaccess = 'Redirect 301 /deleted-page/ https://website.com/new-page/';

htconvert(htaccess);
// `location /deleted-page/ {
//   return 301 https://website.com/new-page/;
// }`

License

MIT © Luke Childs

About

Convert .htaccess redirects to nginx.conf redirects

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published