htaccess Tool

import requests

def access_htaccess(url):
"""Attempt to access the .htaccess file of the given URL."""
htaccess_url = url.rstrip('/') + '/.htaccess'
try:
response = requests.get(htaccess_url)
if response.status_code == 200:
print("Contents of .htaccess file:")
print(response.text)
else:
print(f".htaccess file not found or inaccessible. Status code: {response.status_code}")
except requests.RequestException as e:
print(f"An error occurred: {e}")

def main():
url = input("Enter the target URL (e.g., http://example.com): ")
access_htaccess(url)

if __name__ == "__main__":
main()