Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

The .htaccess file is a configuration file for the Apache web server, allowing configuration settings to be made at a directory-specific level, overriding the server-wide or site-level settings in the main Apache config.

Most (though not all) 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 also has further information about mod_rewrite.

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

The htaccess file is used by the mod_rewrite module of the Apache webserver. It allows URLs to be rewritten for scenarios such as the following

  • Shortcuts such as example.com/info to redirect to another page
  • Redirects from old pages to new pages
  • Password protection of directories and files

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

1689 questions
13
votes
4 answers

What are some resources for learning the ins and outs of .htaccess?

What are resources for learning the various things I can do with .htaccess?
delete
12
votes
1 answer

301 redirects for all except me

I want to have my site down for an hour and I was using order Deny,Allow Deny from all Allow from my.ip.add.ress but I don't like the default error page. Is there a 301 redirect where I can redirect everyone who is not on my IP address to a nice…
Chris Mccabe
  • 223
  • 1
  • 4
8
votes
1 answer

Does adding a huge list of bots on .htaccess slow the site down?

This huge list of known bad bots is useful (GitHub) The list is huge with over 1,800 "known" bots, and I think it's a good thing to add this - I mean - why not? However, my main question is - does it or can so many HTACCESS rules slow the site down?
Henry
  • 415
  • 4
  • 8
6
votes
6 answers

Removing the dot or period from htaccess files - A dangerous move?

Removing the dot or period from htaccess files (and thus making it unhidden) - A dangerous move? I tried to search in Google with the string: Can I remove the dot htaccess But I didn't find anything directly related to this question. The reason for…
user58733
5
votes
2 answers

My .htaccess entry is not working

The below are all my .htaccess entry: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.acethehimalaya\.com$ [NC] RewriteRule (.*) http://www.acethehimalaya.com/$1 [R=301,L] redirect 301 /brochure_request.php…
user2014989
  • 83
  • 1
  • 5
5
votes
3 answers

How to set suhosin.post.max_vars in a htaccess file

I need to add this values to my htaccess: suhosin.request.max_vars = 8000 suhosin.post.max_vars = 8000 If I just add them like that I get an Internal Server Error Which is the right way to include them?
chefnelone
  • 193
  • 1
  • 1
  • 9
4
votes
2 answers

htaccess redirect subfolder to root

In the following scenario, example.com is my homepage. I need to: redirect www to non-www redirect index.html to homepage redirect example.com/store to example.com This is my htaccess code # Switch rewrite engine on RewriteEngine On RewriteBase…
4
votes
1 answer

How to Add expiry header on thirdparty JS and CSS file in WordPress

I am using different plugins in WordPress like Disqus comment system, Theia Post slider and other.. Here is a result from GTmatrix : I want to know how can I add expiry header on third party JS files and CSS files. I want to increase my Y-Slow…
Anas Khan
4
votes
2 answers

access-control-allow-origin not working?

I've seen similar questions asked here but I am still unable to solve this issue. I'm running Typekit and FontAwesome (from CDN) and I get the following error XMLHttpRequest cannot load http://resource.com/example/example. Origin http://mydomain.com…
cballenar
  • 141
  • 2
4
votes
1 answer

Proper caching method with .htaccess

Possible Duplicate: .htaccess and browser caching There are a lot of snippets that enable caching on a website and I don't know which one should I use. The most popular is something like this: ExpiresActive…
user13070
4
votes
0 answers

Why are my HTML resources re-downloading despite having an expiration date a month in the future?

I have set the expiration information for my resources in the .htaccess file as shown below: ExpiresActive on ExpiresByType image/jpeg "access plus 1 month" ExpiresByType text/css "access plus 2 month" ExpiresByType…
HenryHunt
  • 41
  • 2
4
votes
1 answer

How to redirect a specific search result using .htaccess

When searching for "interesting people" the search results page of my website is https://example.com/?s=interesting+people&submit.x=0&submit.y=0 Instead of displaying that search results page I would like this specific search result to 302 redirect…
au_Martin
  • 43
  • 4
3
votes
5 answers

Access Website by domain name only (not IP address)

Let's say I have a website example.com and it points to 12.23.42.31. Now I want that nobody can access my website by the IP address (12.23.42.31). What is the procedure to achieve this? LAMP server with WordPress. Not shared hosting.
amit singh
  • 65
  • 1
  • 1
  • 6
3
votes
2 answers

Redirecting all pages to new website homepage using .htaccess

I want to direct all of the pages (around 700) from my old website, to the homepage of my new website. I found this method to be used in .htaccess: redirectMatch 301 ^/ http://www.newwebsite.co.uk Is this an effective method for redirecting all…
Billy Hudson
  • 133
  • 1
  • 1
  • 3
3
votes
2 answers

How to use .htaccess with exclusions

I want all requests on a domain to be redirected to https, with the exception of just one particular file. I'm not sure how to accomplish this with .htaccess -bash-3.2# cat .htaccess ErrorDocument 404 http://www.example.com RewriteEngine…
bdwarr6
  • 33
  • 2
1
2 3 4 5 6