Questions tagged [.htaccess]

Directory-level configuration file used by Apache web servers. Use this tag if and only if .htaccess content is directly involved in the topic. We know many people are using .htaccess, but kindly ask the members of the community to not use this tag, unless you know it is on-topic in your question. Also notice what the "apache" tag has to say about questions about _configuring_ Apache httpd and their potential off-topicness on stackoverflow

The .htaccess (hypertext access) file is a configuration file for the Apache web server, allowing configuration settings to be made at a directory-specific level. It overrides the server-wide or site-level settings in the main Apache server-level configuration but must be enabled in the server-level configuration to work.

Most (though not all) directory-specific Apache settings can be configured in .htaccess. One of the most common usages for it is URL redirection using mod_rewrite, which is used by many sites for SEO purposes and to provide easier-to-read URLs. The Apache documentation has further information about mod_rewrite as well as simpler solutions for many common use cases.

.htaccess files are also commonly used to define custom error pages (e.g. for 404 errors). They can also be used for specifying directory-specific security and user authentication, configuring the PHP installation, file handlers and MIME types, output compression, and more.

For more information on .htaccess files and how to use them, see the Apache documentation.

More information

Top Questions for reference

  1. Tips for debugging .htaccess rewrite rules
  2. Access-Control-Allow-Origin Multiple Origin Domains?
  3. How to manually create a file with a . dot prefix in windows for example .htaccess
  4. How does RewriteBase work in .htaccess
  5. htaccess redirect to https://www
  6. How to redirect all HTTP requests to HTTPS
  7. Hidden features of mod_rewrite
  8. .htaccess redirect all pages to new domain
  9. Create subdomains on the fly with .htaccess (PHP)
  10. .htaccess mod_rewrite - how to exclude directory from rewrite rule
  11. Leverage browser caching for 3rd party JS

How to ask

  • Make sure you explain how .htaccess is involved in your question
  • Explain the expected behavior, the actual behavior and the difference between the two
  • Show the relevant part of the .htaccess
70056 questions
5
votes
1 answer

codeigniter not work at live page not found error on server

my codeigniter work perfectly on local host but not work at live.my codeigniter is latest version.i also try older.it always show me page not found on redirect. routes.php setting is $route['default_controller'] = "home"; $route['404_override'] =…
5
votes
1 answer

Apache .htaccess: Serving .css files from separate domain?

I'm trying to serve CSS files for my site from a separate domain. I've got the following entry in my site's .htaccess (in the document root): RewriteRule ^templates/*\.css$ http://css.mysite.com/templates/$1 [R=301,L] With the intention of simply…
gellenburg
  • 53
  • 3
5
votes
3 answers

Apache Rewrite: image directory based on HTTP host

My software supports multiple domain names all pointed at the same directory on the server (a different database for each of course). So these domains... www.example1.com www.example2.com www.example3.com ...all point to... /public_html/ In the…
John
  • 10,154
  • 9
  • 79
  • 143
5
votes
1 answer

URL-encoded parameter breaks default Zend rewrite rules

I'm using the standard Zend /public/.htaccess file (shown below). At the moment I'm attempting to forward the user to a specific controller/action, and supply the on-success-redirect URL as a URL parameter. The resulting URL (assembled & encoded via…
Daniel B.
  • 1,410
  • 1
  • 15
  • 37
5
votes
2 answers

For URL rewriting, use .htaccess or PHP to determine content used?

When using URL rewriting for beautification, are there any thoughts on whether to do your content calculations in a PHP script or to hard code it into the .htaccess file? For instance, WP adds the simple rule to the .htaccess file RewriteBase…
edeneye
  • 417
  • 4
  • 12
5
votes
3 answers

Only load a part of a page with jquery

I have a wordpress website and want to load my pages using jquery. I only want to load the content div, so I pass this the url like this: var url = $(this).attr('href') + "#content"; Now when I try to load the page using ajax it loads the url…
Rene Terstegen
  • 7,551
  • 17
  • 49
  • 71
5
votes
1 answer

Why is Apache removing multiple slashes?

This RewriteRule RewriteRule ^test/(.*)$ test.php?url=$1 On this URL mysite.com/test//one///two////three/// Is giving me this result $1=url='one/two/three/' I'm using easyphp if it matters and I like to know why is Apache removing multiple…
Drust
  • 353
  • 1
  • 11
5
votes
2 answers

What redirect code can solve my duplicate homepage?

I've got a problem with a website, and i don't know which code i must use to solve it. I've run a crawl test, which results in the following structure: www.domain.com www.domain.com/ (this is a big problem, because it's duplicate…
5
votes
2 answers

PHP glob() doesnt find .htaccess

Simple question - How to list .htaccess files using glob()?
Tony Bogdanov
  • 6,238
  • 10
  • 45
  • 74
5
votes
2 answers

.htaccess image redirect

I've written a PHP class to add a watermark to an image, it works great when accessed via URL directly. I would like to "redirect" every image to my URL like so: http://www.mysite.com/img.jpg to this …
michaeltintiuc
  • 661
  • 15
  • 30
5
votes
1 answer

Apache RewriteMap Used to Prevent Direct Access to Files

I am trying to use the result of a RewriteMap function to conditionally allow access to a directory. The intention is to read a timestamp from a cookie (my_cookie) and pass it into the RewriteMap (my_rewrite_map_func) which I have defined in…
lizbit
  • 214
  • 1
  • 12
5
votes
1 answer

Making PHP file upload secure with htaccess

I am working on a task to make the PHP file upload secure and my client wants to follow the guideline mention on the website http://www.acunetix.com/websitesecurity/upload-forms-threat.htm We are able to follow all the guidelines mentioned on this…
Harshal
  • 51
  • 1
  • 1
  • 3
5
votes
2 answers

Could .htaccess cause looping?

I'm no hero with .htaccess, but I'm experiencing a problem that I think might be caused by it. The first symptoms: simple changes to my database (like user IP tracking) got done multiple times per request, while the output by the site looks just…
Mr.H
  • 556
  • 4
  • 9
5
votes
3 answers

set_time_limit(0) and "Maximum execution time" PHP

I have a script where I have set: set_time_limit(0) but still get Fatal error: Maximum execution time of 90 seconds exceeded in /home/Feed.php on line 234 I've also tried setting: php_value max_execution_time 120 in the .htaccess file but still…
StudioTime
  • 18,874
  • 30
  • 103
  • 186
5
votes
1 answer

mod_geoIP installation help?

I'm installing mod_geoIP for cpanel based on these instructions (not very detailed, hence this question) At this point, I've installed the module as instructed. I've also downloaded the csv file for the GeoLite Country. AM I missing anything? I…
Paul
  • 11,011
  • 28
  • 81
  • 137
1 2 3
99
100