顯示具有 Web Server 標籤的文章。 顯示所有文章
顯示具有 Web Server 標籤的文章。 顯示所有文章

2025-11-26

PowerShell 更新 IIS Site Bind SSL Cert

$PublishedURL = "www.contoso.com"
$IISSiteName = "www.contoso.com"

$PFXPath = "C:\Cert\Cert\"
$Password = "password"

$PFXFullPath = "$PFXPath$PublishedURL.pfx"

$pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$pfx.Import($PFXFullPath, $Password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::EphemeralKeySet)

Import-Module IISAdministration

2025-04-28

URL Parsing by PowerShell

URL Parsing by PowerShell

$URL = "https://api.contoso.com/level1/level2/Script.php?index=1&page=2&content=3";
$URI = [System.Uri]$URL;

Add-Type -AssemblyName System.Web;
$ParsedQueryString = [System.Web.HttpUtility]::ParseQueryString($URI.Query);
$QueryParams = New-Object -TypeName PSObject;
$i=0;
foreach($QueryStringObject in $ParsedQueryString){
    $QueryParams | Add-Member -MemberType NoteProperty -Name $QueryStringObject -Value $ParsedQueryString[$i];
    $i++;
};

$URI | fl;
$QueryParams.PSObject.Properties.Name;
$QueryParams;


2022-09-27

Apache 圖片網址根據解析度 Rewite

Line Bot 發送圖片需要有各種解析度的 URL
但若要產生各種解析度的圖片會耗費太多時間造成 Timeout
所以直接寫 Rewrite 到最高解析度的圖片 URL 就好

寫在 Virtual Host 段
如果有多個不同路徑都會用到相同功能可以寫多個 Directory

 <VirtualHost *:80>

<Directory "${SITEROOT}/www.contoso.com/image">
<IfModule rewrite_module>
RewriteEngine On

2020-12-11

Apache .htaccess 去除網址最後一個元素

傳 imagemap Message Type 的圖片 URL 給 Line 的時候
Line 會用 https://xxx/Path/To/image.png/1040 取代 https://xxx/Path/To/image.png

由於我只要提供一張圖片而已不區分解析度,所以想用 mod_rewrite 的方式處理
因為不熟悉正規表達式,網路搜尋老半天後暫時只能用以下方式處理

不知道那個 /Path/To/ 要怎麼用變數取代,否則就只能寫 .htaccess 在該路徑
並把 Path/To 寫 Hard Code 進去 Orz

RewriteEngine On
RewriteRule ^(.*)/1040 /Path/To/$1 [L]

如果有人會的話竟請不吝提供 m(_ _)m

2020-12-08

Integrated Windows Authentication with Apache 2.4 on Windows

Download mod_authnz_sspi from Here (The ApacheHaus US)

Uncompress it and copy mod_authnz_sspi.so to Apache\modules

Add Configuration in http.conf

LoadModule authnz_sspi_module modules/mod_authnz_sspi.so

2018-11-05

Apach Web Server 限制存取 IP


<Directory "D:/WebSite/www.contoso.com">
Options FollowSymLinks
AllowOverride All
Order Deny,Allow
Deny From All
Allow From 192.168.0.0/24 192.168.1.0/24 192.168.2.0/24
</Directory>