排除特定文件的重写URL

时间:2019-02-24 16:17:15

标签: angular .htaccess

我有一个Angular网站,并使用以下.htaccess文件来重写url并使用struct MyStruct: Encodable { var a:Int = 0 var b:Int = 0 var context = .full enum CodingKeys: String, CodingKey { case a case b } enum Context { case summary, full } // But I want to write is something like this func encode(to encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(a, forKey: .a) if context == .full { try container.encode(b, forKey: .b) } } } var myObject = MyStruct() myObject.a = 10 myObject.b = 5 myObject.context = .summary let jsonEncoder = JSONEncoder() do { let jsonData = try jsonEncoder.encode(myObject) let jsonString = String(data: jsonData, encoding: .utf8)! print(jsonString) } catch { print(error) }

index.html

我需要排除对<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^(.*) /index.html [NC,L] </IfModule> 的请求,尝试了许多解决方案,但没有成功,例如:

static.php

如何排除对https://example.com/static.php的请求被重写或重定向

谢谢

1 个答案:

答案 0 :(得分:0)

您可以使用以下规则:

RewriteEngine on

RewriteCond %{REQUEST_URI} !/static\.php$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.html [L]