{"id":26409473,"url":"https://github.com/simone-di-paolo/apache-rewrite-rules-tool","last_synced_at":"2025-03-17T19:34:29.480Z","repository":{"id":41846576,"uuid":"475169843","full_name":"simone-di-paolo/apache-rewrite-rules-tool","owner":"simone-di-paolo","description":"A simple Rewrite Rules tool written in Python for Apache","archived":false,"fork":false,"pushed_at":"2023-01-12T12:44:40.000Z","size":45,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-06T20:26:35.386Z","etag":null,"topics":["adobe-experience-manager","aem","apache","rewrite-rules"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simone-di-paolo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-28T20:33:23.000Z","updated_at":"2022-03-29T12:24:21.000Z","dependencies_parsed_at":"2023-02-09T12:01:31.681Z","dependency_job_id":null,"html_url":"https://github.com/simone-di-paolo/apache-rewrite-rules-tool","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simone-di-paolo%2Fapache-rewrite-rules-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simone-di-paolo%2Fapache-rewrite-rules-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simone-di-paolo%2Fapache-rewrite-rules-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simone-di-paolo%2Fapache-rewrite-rules-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simone-di-paolo","download_url":"https://codeload.github.com/simone-di-paolo/apache-rewrite-rules-tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244097399,"owners_count":20397597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adobe-experience-manager","aem","apache","rewrite-rules"],"created_at":"2025-03-17T19:34:28.881Z","updated_at":"2025-03-17T19:34:29.471Z","avatar_url":"https://github.com/simone-di-paolo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"left\"\u003e\n  \u003ca href=\"https://github.com/simone-di-paolo\"\u003e\n    \u003cimg src=\"resources/img/sdp-logo-black.png\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"left\"\u003e\n  \u003ch3\u003eSIMPLE REDIRECT TOOL GENERATOR FOR APACHE\u003c/h3\u003e\n\n\u003ch3 dir=\"auto\"\u003e\u003ca id=\"user-content-what-are-vine-copulas\" class=\"anchor\" aria-hidden=\"true\" href=\"#what-are-vine-copulas\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003eWhat is this script for?\u003c/h3\u003e\n\n\u003cp text-align=\"center\"\u003e\n    This is a simple script in Python that will take the first two columns of an Excel file, extract its contents and use the text inside to generate a new rewriter-rules.txt file with rewrite rules for Apache.\n\u003c/p\u003e\n\u003cp\u003eAn example of the result of each rows inside the rewrited-rules.txt is the following:\u003c/p\u003e\n\n\u003cpre\u003e# SCTASK1234567 --- https://www.test.co.uk/en/some/old/path.html =\u003e https://www.test.co.uk/en/a/new/path.html\nRewriteRule ^/en/some/old/path.html$ https://%{SERVER_NAME}/en/a/new/path.html? [NC,L,R=301,ENV=REDIRECTCACHE:1]\u003c/pre\u003e\n\n\u003cp\u003eWhere the first line is a comment that shows:\u003c/p\u003e\n\u003cul\u003e\n  \u003cli\u003e\u003cb\u003eSCTASK1234567:\u003c/b\u003e it's the number of the Service Task (from Jira). You can leave it blank if you want\u003c/li\u003e\n  \u003cli\u003e\u003cb\u003ehttps://www.test.co.uk/en/some/old/path.html:\u003c/b\u003e the old URL\u003c/li\u003e\n  \u003cli\u003e\u003cb\u003ehttps://www.test.co.uk/en/a/new/path.html:\u003c/b\u003e the new URL\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThe second link is created this way: \u003c/p\u003e\n\u003cul\u003e\n  \u003cli\u003e\u003cb\u003eRewriteRule:\u003c/b\u003e it's the beginning of the RewriteRule\u003c/li\u003e\n  \u003cli\u003e\u003cb\u003e^/en/some/old/path.html:\u003c/b\u003e it's the old path starting from the language from the old URL\u003c/li\u003e\n  \u003cli\u003e\u003cb\u003ehttps://%{SERVER_NAME}/en/a/new/path.html:\u003c/b\u003e it's the page where the user will be redirected from the old path\u003c/li\u003e\n  \u003cli\u003e\u003cb\u003e[NC,L,R=301,ENV=REDIRECTCACHE:1]:\u003c/b\u003e those are redirect rules flags\u003c/li\u003e\n    \u003cul\u003e\n      \u003cli\u003e\u003cb\u003eNC:\u003c/b\u003e thise flag causes the RewriteRule to be matched in a case-insensitive manner\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eL:\u003c/b\u003e this flag, in most contexts, means that if the rule matches, no further rules will be processed.\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eR=301:\u003c/b\u003e it's the redirect type, 301 or 302 (choose wisely)\u003c/li\u003e\n      \u003cli\u003e\u003cb\u003eENV=REDIRECTCACHE:1:\u003c/b\u003e With the [E], or [env] flag, you can set the value of an environment variable (in this case REDIRECTCACHE with value 1). \u003c/li\u003e\n    \u003c/ul\u003e\n  \u003c/ul\u003e\n  \u003ci\u003eOfficial documentation about flags: https://httpd.apache.org/docs/2.4/rewrite/flags.html\u003c/i\u003e\n  \n  \u003ch3\u003eSETTING UP VARIABLES\u003c/h3\u003e\n  \n  \u003cp\u003eOpen the script with an editor like Notepad++ and edit the following variables as you prefer:\n  \u003cul\u003e\n    \u003cli\u003e\u003cb\u003estartFromWhichRow = 1\u003c/b\u003e  # in case the first row of your Excel file has no rules but only column titles put 1, otherwise 0\u003c/li\u003e\n    \u003cli\u003e\u003cb\u003esheetNumber = 0\u003c/b\u003e  # the index of the excel sheet you want to process, if doOnlyOneSheet is False it will do them all starting from this index\u003c/li\u003e\n    \u003cli\u003e\u003cb\u003edoOnlyOneSheet = False\u003c/b\u003e  # if for any reason you need to do one file sheet at a time put this to True (with capital T letter)\u003c/li\u003e\n    \u003cli\u003e\u003cb\u003eserviceTaskID = \"SCTASK1234567\"\u003c/b\u003e  # number of the Jira Service Task that is inserted in the line of the comments (if neededm otherwise leave it blank)\u003c/li\u003e\n    \u003cli\u003e\u003cb\u003eredirectType = \"301\"\u003c/b\u003e  # can be 301 or 302, your choice\u003c/li\u003e\n    \u003cli\u003e\u003cb\u003erewriteRulesFlags = [\"NC\", \"L\", \"R=\"+redirectType, \"ENV=REDIRECTCACHE:1\"]\u003c/b\u003e  # add all the redirect flags you need into this arrays of strings\u003c/li\u003e\n  \u003c/ul\u003e\n  \n  \u003cp\u003e\u003cb\u003eN.B.\u003c/b\u003e REMEMBER TO CHANGE ADD CORRECT PATHS TO THE FILES THAT YOU'LL READ AND WRITE!\u003c/p\u003e\n  \n  \u003ch3\u003eINSTALLATION GUIDE\u003c/h3\u003e\n  \n  \u003cp\u003eTo make this script work you need to install Python and xlrd library.\u003c/p\u003e\n  \u003cp\u003eYou can download the latest version of Python from those links for \u003ca href=\"https://www.python.org/downloads/\" target=\"_blank\"\u003eWindows\u003c/a\u003e, \u003ca href=\"https://www.python.org/downloads/source/\" target=\"_blank\"\u003eLinux/UNIX\u003c/a\u003e, \u003ca href=\"https://www.python.org/downloads/macos/\" target=\"_blank\"\u003eMacOS\u003c/a\u003e.\u003c/p\u003e\n  \n  \u003cp\u003eIf you are using .xlsx files, you'll need to install this specific version:\u003c/p\u003e\n  \u003cpre\u003epip install xlrd==1.2.0\u003c/pre\u003e\n  \u003cp\u003eOtherwise, if you are using .xls files, then, you'll need to install the latest version:\u003c/p\u003e\n  \u003cpre\u003epip install xlrd\u003c/pre\u003e\n  \n  \u003cp\u003eOnce done, navigate into your folder with cmd/terminal and launch (N.B. use your python version into the next command):\u003c/p\u003e\n  \u003cpre\u003epython redirect-tool.py\u003c/pre\u003e\n  \n  \u003cp\u003eNow, you will find your new/updated file rewritedRules.txt into your folder destination (specified inside the script).\u003c/p\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimone-di-paolo%2Fapache-rewrite-rules-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimone-di-paolo%2Fapache-rewrite-rules-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimone-di-paolo%2Fapache-rewrite-rules-tool/lists"}