Thursday, June 26, 2025
Simplest rules to Redirect using .htaccess
How to write rewrite rule (URL rewriting, mod_rewrite)
(1) Redirect site from http to https :
Add the below in .htaccess file in public_html
===================================================
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
===================================================
(2) Redirecting a domain to another domain via .htaccess
Example :- redirect shaz.com to google.com
===================================================
RewriteEngine on
RewriteCond %{HTTP_HOST} ^shaz\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.shaz\.com$
RewriteRule ^/?$ “http\:\/\/www\.google\.com\/” [R=301,L]
===================================================
(3) Redirect users to access the site with WWW
example :- redirect shaz.com to www.shaz.com
Add the below in .htaccess file
===================================================
RewriteEngine on
RewriteCond %{HTTP_HOST} ^shaz\.com$ [NC]
RewriteRule ^(.*)$ http://www.shaz.com/$1 [L,R=301]
===================================================
(4) Redirect page to another page within public_html
example :- to redirect home.html to index.php
===================================================
RewriteEngine on
RewriteRule ^home.html$ index.php
===================================================
example2 :- rewrite site shaz.com/kb/index.php to shaz.com/blog/index.html
go to kb directory and create a .htaccess file
+++++++++++++++++++++++++++++++++++++++++++++++++++
#cd public_html/kb
#touch .htaccess
#vi .htaccess
+++++++++++++++++++++++++++++++++++++++++++++++++++
===================================================
RewriteEngine on
RewriteRule ^index.php$ /blog/index.html
===================================================
Step-by-Step: Installing Home Assistant OS on VMware vSphere
Prerequisites
- VMware vSphere 7.0+ access
- Download
haos_ova-12.3.vmdk.xz
from GitHub Release 12.3 - 7-Zip or similar extraction tool
Installation Steps
- Prepare the VMDK:
- Extract the downloaded
.xz
file to gethaos_ova-12.3.vmdk
- Rename to
home-assistant.vmdk
- Extract the downloaded
- Create Virtual Machine:
- Guest OS Family: Linux
- Version: Other Linux 5.x kernel 64-bit
- Hardware:
- 2 vCPU minimum
- 2 GB RAM minimum
- Remove all default storage devices
- Upload VMDK to Datastore:
- Use Datastore Browser to upload
home-assistant.vmdk
- Use Datastore Browser to upload
- Convert Disk Format: (Required for vSphere compatibility)
vmkfstools -i /vmfs/volumes/[DATASTORE]/home-assistant.vmdk \ /home-assistant-converted.vmdk
- Configure Virtual Hardware:
- Add SCSI Controller: LSI Logic SAS
- Attach converted VMDK as existing hard disk
- Network: Bridged adapter
- Enable UEFI Boot:
- Edit VM Settings > VM Options > Boot Options
- Firmware: EFI
- Disable Secure Boot
First Boot Configuration
- Power on the VM
- Access via web browser:
http://homeassistant.local:8123
- or use assigned IP address
Troubleshooting Tips
Issue | Solution |
---|---|
"Unsupported disk type" error | Re-run vmkfstools conversion |
Boot failure | Verify EFI settings in VM options |
Network unreachable | Check bridged network configuration |
After successful installation, you can expand storage or add USB controllers for Zigbee/Z-Wave devices through vSphere's hardware settings.
Friday, April 25, 2025
How to Configure Static IP Address Using nmcli in Linux
Configuring a static IP address is a common task for Linux administrators, especially when setting up servers or virtual machines that require consistent network settings. The nmcli command-line tool, part of NetworkManager, provides a powerful and scriptable way to manage network connections without a GUI. In this guide, we’ll walk through the essential nmcli commands to set a static IPv4 address, gateway, DNS, and disable IPv6 for a network interface.
Step-by-Step: Setting a Static IP Address with nmcli
Let’s assume your network interface is named ens33. Here’s how to configure it:
- Assign a Static IPv4 Address
nmcli con mod ens33 ipv4.addresses "172.16.3.150/16"
This sets the IP address to 172.16.3.150 with a subnet mask of 255.255.0.0 (CIDR /16). - Set the Default Gateway
nmcli con mod ens33 ipv4.gateway "172.16.0.1"
This command configures the default gateway for outgoing traffic. - Configure DNS Server
nmcli con mod ens33 ipv4.dns "8.8.8.8"
This sets Google’s DNS server for name resolution. You can add multiple DNS servers by separating them with a comma, e.g.,"8.8.8.8,8.8.4.4"
. - Disable IPv6 (Optional)
nmcli con mod ens33 ipv6.method "disabled"
If your environment does not use IPv6, disabling it can simplify network troubleshooting and improve security. - Set IPv4 Method to Manual
nmcli con mod ens33 ipv4.method manual
This ensures that the interface uses manual (static) configuration instead of DHCP.
Applying the Changes
After making these changes, you need to bring the connection down and back up for the settings to take effect:
- nmcli con down ens33 nmcli con up ens33
Example: Complete Static IP Setup Script
- nmcli con mod ens33 ipv4.addresses "172.16.3.150/16"
- nmcli con mod ens33 ipv4.gateway "172.16.0.1"
- nmcli con mod ens33 ipv4.dns "8.8.8.8"
- nmcli con mod ens33 ipv6.method "disabled"
- nmcli con mod ens33 ipv4.method manual
- nmcli con down ens33 nmcli con up ens33
Additional Tips
- Check Connection Name: Use
nmcli con show
to list all available connections and confirm your interface name (e.g., ens33). - Disable IPv6 for Other Connections: Replace ens33 with your actual interface name as needed.
- Verify Configuration: After applying changes, use
ip addr
andnmcli dev show ens33
to verify your settings.
Summary Table: Key nmcli Commands
Command | Description |
---|---|
nmcli con mod ens33 ipv4.addresses "IP/CIDR" | Set static IP address and subnet |
nmcli con mod ens33 ipv4.gateway "GATEWAY" | Set default gateway |
nmcli con mod ens33 ipv4.dns "DNS" | Set DNS server(s) |
nmcli con mod ens33 ipv6.method "disabled" | Disable IPv6 |
nmcli con mod ens33 ipv4.method manual | Set IPv4 configuration to manual |
nmcli con down ens33 | Deactivate the connection |
nmcli con up ens33 | Activate the connection |
With these nmcli commands, you can quickly and reliably configure static IP settings on your Linux systems, making network management more efficient and consistent.