htconvert

1.0.7 • Public • Published

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

Package Sidebar

Install

npm i htconvert

Weekly Downloads

12

Version

1.0.7

License

MIT

Last publish

Collaborators

  • lukechilds