i want htaccess file how get

Dani AI

Generated

asked how to get an .htaccess file; pointed to reading material and asked about the environment. For a local Apache installation it’s important to understand that an .htaccess file is a per-directory override mechanism — any directive allowed there depends on the server’s global configuration, and when full config access exists it’s usually better (faster and cleaner) to put those directives in the main Apache config instead. See the official Apache tutorial for the details. (Apache .htaccess HowTo). (httpd.apache.org)

Typical steps for a localhost (XAMPP/WAMP) setup: edit the Apache config inside the stack’s install folder (for XAMPP the main file is under <XAMPP_HOME>\apache\conf\httpd.conf), make sure the rewrite functionality is available and that the DocumentRoot/VirtualHost has an appropriate AllowOverride setting (All or at least FileInfo for URL rewrites). After editing the config the Apache service needs to be restarted via the stack control panel or service manager (no OS reboot required). (XAMPP FAQ — main config files). (apachefriends.org)

Quick, non-invasive test to confirm .htaccess is being read (Windows notes): create a file named ".htaccess" in the document root — Notepad → Save As, set “All files” and use the quoted name ".htaccess", or from a shell: echo. > .htaccess. Drop this minimal redirect in the file to check processing:

# quick test (.htaccess)
Redirect /testme.html /index.php

Visiting should load index.php if .htaccess is active. (Windows filename tip: StackOverflow discussion). (stackoverflow.com)

Troubleshooting pointers: check Apache’s error log (XAMPP: apache\logs\error.log), list loaded modules with httpd -M or apachectl -M to confirm the rewrite module, and verify the AllowOverride change applies to the exact Directory/VHost used. Remember that mod_rewrite has per-directory behavior (leading slash is stripped and Options FollowSymLinks can be required), so consult the mod_rewrite notes when rules don’t behave as expected. If problems persist, place rules in a <Directory> block in the main config instead of relying on .htaccess. (hostwinds.com)

Recommended Answers

All 4 Replies

You search Google for info about the .htaccess file and try some tutorials to create one. Then, if you can't figure out how to create one or if you run into problems, you post your questions here, and we can help you.

Edit: A useful link given by fireburner29 in this post:

Are you on localhost..? shared hosting server..?

Care to explain more on your server details.. :)

localhost

on localhost try to edit file httpd.conf found in "C:\Windows"
search for line
#LoadModule rewrite_module modules/mod_rewrite.so
and remove # to activate rewrite module, restart your PC and try to learn basic rules for htaccess like

Options All -Indexes  # prevent user from viewing folder content
RewriteEngine on  # switch rewrite ON
RewriteRule ^(.*).html$ $1.php  #convert any php page to html page in url address

as mentioned try to read a guide for making htaccess file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.