diff --git a/.gitignore b/.gitignore
index abc642dc8d..4b5208332f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,4 +30,5 @@ project.lock.json
.testPublish/
.idea/
.vscode/
-
+*.nuget.props
+*.nuget.targets
diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleBuilder.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleBuilder.cs
index e9bc6b36df..8e93d1db16 100644
--- a/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleBuilder.cs
+++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/RuleBuilder.cs
@@ -178,8 +178,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite
if (flags.GetValue(FlagType.Env, out flag))
{
- // parse env
- _actions.Add(new ChangeEnvironmentAction(flag));
+ throw new NotSupportedException(Resources.Error_ChangeEnvironmentNotSupported);
}
if (flags.HasFlag(FlagType.Forbidden))
diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeEnvironmentAction.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeEnvironmentAction.cs
deleted file mode 100644
index c0b314a643..0000000000
--- a/src/Microsoft.AspNetCore.Rewrite/Internal/UrlActions/ChangeEnvironmentAction.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNetCore.Rewrite.Internal.UrlActions
-{
- public class ChangeEnvironmentAction : UrlAction
- {
- public ChangeEnvironmentAction(string env)
- {
- // TODO
- throw new NotImplementedException("Changing the environment is not implemented");
- }
-
- public override void ApplyAction(RewriteContext context, MatchResults ruleMatch, MatchResults condMatch)
- {
- // Do stuff to modify the env
- throw new NotImplementedException("Changing the environment is not implemented");
- }
- }
-}
diff --git a/src/Microsoft.AspNetCore.Rewrite/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Rewrite/Properties/Resources.Designer.cs
index 25261d8664..3c2e0d6b64 100644
--- a/src/Microsoft.AspNetCore.Rewrite/Properties/Resources.Designer.cs
+++ b/src/Microsoft.AspNetCore.Rewrite/Properties/Resources.Designer.cs
@@ -154,6 +154,22 @@ namespace Microsoft.AspNetCore.Rewrite
return GetString("Error_IntegerMatch_FormatExceptionMessage");
}
+ ///
+ /// Error adding a mod_rewrite rule. The change environment flag is not supported.
+ ///
+ internal static string Error_ChangeEnvironmentNotSupported
+ {
+ get { return GetString("Error_ChangeEnvironmentNotSupported"); }
+ }
+
+ ///
+ /// Error adding a mod_rewrite rule. The change environment flag is not supported.
+ ///
+ internal static string FormatError_ChangeEnvironmentNotSupported()
+ {
+ return GetString("Error_ChangeEnvironmentNotSupported");
+ }
+
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);
diff --git a/src/Microsoft.AspNetCore.Rewrite/Resources.resx b/src/Microsoft.AspNetCore.Rewrite/Resources.resx
index 70a314f06b..7b477cc447 100644
--- a/src/Microsoft.AspNetCore.Rewrite/Resources.resx
+++ b/src/Microsoft.AspNetCore.Rewrite/Resources.resx
@@ -1,17 +1,17 @@
-
@@ -144,4 +144,7 @@
Syntax error for integers in comparison.
+
+ Error adding a mod_rewrite rule. The change environment flag is not supported.
+
\ No newline at end of file
diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RuleBuilderTest.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RuleBuilderTest.cs
new file mode 100644
index 0000000000..df1a16adf1
--- /dev/null
+++ b/test/Microsoft.AspNetCore.Rewrite.Tests/ApacheModRewrite/RuleBuilderTest.cs
@@ -0,0 +1,24 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite;
+using Xunit;
+
+namespace Microsoft.AspNetCore.Rewrite.Tests
+{
+ public class RuleBuilderTest
+ {
+ [Fact]
+ // see https://httpd.apache.org/docs/2.4/rewrite/advanced.html#setenvvars
+ public void AddAction_Throws_ChangeEnvNotSupported()
+ {
+ var builder = new RuleBuilder();
+ var flags = new Flags();
+ flags.SetFlag(FlagType.Env, "rewritten:1");
+
+ var ex = Assert.Throws(() => builder.AddAction(null, flags));
+ Assert.Equal(Resources.Error_ChangeEnvironmentNotSupported, ex.Message);
+ }
+ }
+}
\ No newline at end of file