Questions tagged [.htaccess]

Directory-level configuration file found mostly on Apache web servers

The htaccess file is a supplemental configuration file used by Apache to modify the default configuration as it applies to the directory the htaccess file it in (as well as all the files and subdirectories in that directory).

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.
Source: Apache manual

The directives allowed in htaccess files are governed from the main Apache configuration files by means of the AllowOverride directive.

The most common use is in conjunction with the mod_rewrite and security modules of the Apache webserver. Mod_rewrite 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
  • virtual directories (directories which actually appear elsewhere in the file system)

The most common security applications are:

  • Password protection of directories and files

For more information see the mod_rewrite and aaa documentation.

2807 questions
1
vote
1 answer

Apache .htaccess - If directive to evaluate if home is the current page

I'm just trying to set a header if the loaded page is home (/), however, I can't manage to do that. What I've tried: #let's find var value - its echo / on the header PassEnv REQUEST_URI Header always set Echo %{REQUEST_URI}e
Uly
  • 13
  • 4
1
vote
1 answer

.htaccess Redirect 301 - Single pages work fine, homepage doesn't

I'm trying to redirect some specific pages to the new ones on my new site (these redirects work fine) and, finally, my homepage OR (even better) my homepage and all the pages which I didn't redirect singularly to my new site home. This is how my…
1
vote
2 answers

do not process rule to htaccess

what is the rule for htaccess that makes all files text ? like .php .py .pl whatever will be no different than .txt, source code should appear on the screen without execution. thx.
Devrim
  • 1,187
  • 4
  • 16
  • 29
1
vote
0 answers

Public WordPress Website unaccessible from inside active directory with same domain name, but simple html file is accessible

a client uses the same corporate domain for his internal network / office365 installation as for the public website. The website and domain are hosted on a shared host, the site is serviced by me. After installing the internal network using the same…
1
vote
1 answer

Difficulty accessing folders .htaccess

I need to migrate a site running on Prestashop 1.6.1.10 to the latest version. I have a problem: I uploaded the new version to a new folder called shop, but I can't access it due to .htaccess. Here is the content of the current…
1
vote
1 answer

.htaccess order deny,allow rule not working Windows

i have two .htaccess setup, One in the htdocs Main Folder with a .htpasswd file attached thats what it looks like rn ErrorDocument 404 /index.html AuthName "Protected Area" AuthType Basic AuthUserFile C:\xampp\htpwdfolder\.htpasswd require…
1
vote
1 answer

Bad Request from RewriteRule after putting Directive

I am building .htaccess for both localhost and godaddy when I stumbled upon this issue. RewriteEngine on SetEnvIf HOST ^localhost$ LOCAL=/company SetEnvIf HOST ^((?!localhost).)+ LOCAL=/ RewriteRule (.+)…
NewWeiNern
  • 13
  • 3
1
vote
0 answers

Redirect/Rewrite for directory if it contains a certain file extension inside

I have been stuck on this issue and have not been able to find a solution. I am using Apache 2.4.41. I am attempting to create a RewriteRule on a site if the currently viewing folder has any files inside with a certain file extension (for this…
Ookinder
  • 11
  • 2
1
vote
1 answer

.htaccess redirect root to i18n content

I'm facing problem with .htaccess and have not idea how to solve it. Our webpage is exposed on two domains: example.de and example.com. I would like to redirect user to i18n content when user request root: https://example.com/ URL should be…
1
vote
1 answer

How can i write a simple rewrite rule in htacess for a file in the sites root directory?

Ive been trying to get my sites htacess to provide effective rewrites for my filepages but im doing something wrong. My directory structure is very simple. All my files are in the root folder. So far my htacess looks like this. RewriteEngine…
1
vote
0 answers

CORS and Preflight problems while making api calls

I have some CORS and preflight problems with my software I can't solve. To test it I was ursing a cors test site to simulate it. When I make an api request to my server application I get the following error: Access to XMLHttpRequest at…
TmCrafz
  • 139
  • 1
  • 9
1
vote
1 answer

CORS conflict after enabling FPM in PHP

In the .htaccess file on my web server, I have the following CORS header set: Header set Access-Control-Allow-Origin "example.com" In one of my PHP scripts, that I frequently call while working from localhost, I have this header…
1
vote
1 answer

Apache2 - Define two working Auth Providers

I want to define two different auth providers in my apache2 .htaccess in case one fails (the desired one is ldap but i want to be able to login even if ldap fails via local htpasswd file) I tried this but i cant get it to work since apache complains…
Nico
  • 135
  • 4
1
vote
1 answer

.htaccess multiple 301 redirects

I am moving a blog hosted on an Apache server to a new domain. The permalinks are kept the same for the blog posts but there are a few pages where the url slug will change on the new domain. My question is if the following is possible and how I…
1
vote
1 answer

Apache FilesMatch (global config) priority over local .htaccess

I want to protect all Wordpress admin interfaces (wp-login.php/wp-admin) in my server. To do this, I want to create a global config in Apache, asking for a fixed user/password (HTTP basic authentication), before reach the real WordPress login page.…
Arvy
  • 131
  • 8
1 2 3
99
100