All Questions
Tagged with apache-2.4 .htaccess
385
questions
0
votes
2
answers
65
views
IF statement based on comparison with %{REQUEST_URI} in .htaccess doesn't work
I'm trying to send a custom header for pages that start with /test-live/
The code I tried:
<If "%{REQUEST_URI} =~ m#^/test-live/#">
Header always set X-Frame-Options "...
0
votes
0
answers
21
views
Apache - How to compress (gzip) only specific calls
I have PHP application served with Apache 2.4
I need the apache to compress (mod_deflate - gzip) calls for specific users. So the application should decides dynamically which calls gets gzipped.
I was ...
0
votes
0
answers
25
views
How to restrict user to view directory If subDomain Url format is wrong
Currently, I am redirecting all my subdomains to a particular folder using the .htaccess file. Below I have mentioned my .htaccess file code
<IfModule mod_rewrite.c>
RewriteEngine On
# ...
0
votes
1
answer
315
views
getting error Content Encoding Error (ERR_CONTENT_DECODING_FAILED) with Apache served pre-compressed .br (Brotli) files
How can I get Apache to serve pre-compresses Brotli files?
With Chrome I am getting
net::ERR_CONTENT_DECODING_FAILED 200
I made my pre-compressed .br (Brotli) files from minimized .html files (.min....
0
votes
0
answers
526
views
configuring content-security-policy for apache virtual hosts
I have Apache 2.4 with these sites configured in the httpd-vhosts.conf file:
<VirtualHost *:80 *:8080 *:8084>
DocumentRoot "c:\apache_php\sites\public"
ServerName www.mydomain....
2
votes
3
answers
513
views
Apache 2.4.51 bypass Basic Auth for specific query string
I need Basic Auth on my website, except if a specific hash is present in the URL.
www.example.com => Authentication required
www.example.com/whatever => Authentication required
www.example.com/...
0
votes
0
answers
74
views
In .htaccess, can I pass on "OPTIONS *" to be handled by PHP?
I have a RewriteRule .* index.php to catch everything
Everything else seems to pass through just fine, even OPTIONS /. But Apache doesn't seem to let me handle OPTIONS *, and in fact just returns a ...
1
vote
1
answer
191
views
Apache RedirectMatch not matching double slash
I want to redirect URLs with multiple consecutive slashes (e.g. //) in the path to have only one consecutive slash, e.g.
https://example.com/a//b/c/ → https://example.com/a/b/c/.
My .htaccess file ...
-1
votes
1
answer
183
views
.htaccess makes WordPress Dashboard very very slow
Today I suddenly find the WordPress Admin dashboard is very very slow. It takes about 60s or more to access the post list, plugin list, etc. Or will just show an time-out error.
I try the following ...
0
votes
1
answer
67
views
Is it possible to set up .htaccess rule for incoming traffic from 301 redirect?
We have a permanent 301 redirect that is set up for an old site that is now being redirected to a page on a new site. Is it even possible to set up an .htaccess rule on our new sites Apache server to ...
1
vote
1
answer
188
views
What determines the name of Apache PHP Handlers?
When configuring an Apache server to use a Handler to run PHP code, I'm familiar with adding a line similar to below in httpd.conf or .htaccess:
AddHandler application/x-httpd-php81 .php
This tells ...
1
vote
1
answer
704
views
how to run next.js using NODE and react.js at the same time on apache server
I have to run 2 different apps on the same domain at the same time. I want to forward all requests to localhost:3000, if url contains /presscenter, if not, default should be my react.js application. ...
0
votes
0
answers
103
views
Block access to xmlrpc symlink file with htaccess
I have a WordPress site I am versioning with the help of symbolic links on an Apache/2.4.52 (Ubuntu) server with Nginx as a reverse proxy.
The directory structure is as follows:
example.com
wp-admin ...
0
votes
0
answers
150
views
REQENV and SETIF If statement isn't evaluating correctly
....or it is and I've missed something.
So I have a website that can only be accessed via certain IPs. A new development is that I want some of the pages on the site to be open and freely available to ...
1
vote
1
answer
454
views
Default WordPress .htaccess rewrites causes default server page to load due to no default index page present for the root URL
I could really do with some help here please. I know this is a WordPress issue now through testing.
If I allow .htaccess to process rewrites on my Wordpress sites by adding AllowOverride FileInfo to ...
1
vote
1
answer
234
views
Restrict access to specific http_host with apache 2.4.x .htaccess
I'm wondering if anyone knows how to approach this predicament I am facing using .htaccess.
I have a website that is accessible using 2 different domains. For one of the domains, I only want the ...
1
vote
1
answer
346
views
Trapping misformatted paths to Redirect to 404 instead of returning 403
Owing to an error long ago our company web site has been serving image URLs containing a significant amount of white space.
E.g.
http://www.example.com/ /assets/ProductPhotos/...
0
votes
0
answers
129
views
Serve mixed case files case-insensitive on Linux Apache without mod_speling?
On my media subdomain (nice separation of concerns, also for rulesets)
I have files which are in Mixed-Case-intentionally (for maximum semantics, also for downloads)
which I want to serve case-...
0
votes
1
answer
93
views
Redirect rules for multiple enviroments
I have written a set of rules for 3 different environments on the same server. In a nutshell I would redirect the users to the Dev, Stage and Prod single sites. Also enforce https and www for the ...
0
votes
0
answers
213
views
AlmaLinux HTTPD will not recognize the error with .htaccess
Product version: Plesk Obsidian 18.0.47.5
OS version: AlmaLinux 8.7 x86_64
The problem is Apache / HTTPD would not recognize to error its .htaccess from when editing the file at AllowOverride None to ...
1
vote
0
answers
119
views
Apache 2.4 "client denied by server configuration" caused by Require expr - even though the request succeeds
Our apache error log is littered with messages saying client denied by server configuration, even though the htaccess configuration is working as intended.
Here is the relevant bit of the htaccess:
...
1
vote
1
answer
56
views
Apache ToLower on all Wordpress pages (not PDF/CSS/JS)
I'm having issues performing a 301 redirection of URLs that contain capitals to lowercase, excluding static files (PDF/CSS/JS/JPEG/JPG/PNG/WEBP...etc). For example:
https://www.example.com/Page/ would ...
1
vote
1
answer
394
views
htaccess redirect all subpages to parent page except for some parent pages
I want to match all subpages to parent pages, am using wordpress, will that mess up the images and wordpress files?, And I have tags and categories, and I want to exclude them from this rule.
...
1
vote
1
answer
390
views
Apache htaccess ruleset: Try request as: 1) file as-is 2) file + .html suffix 3) DirectoryIndex 4) Else to index.php CMS router
I'd like to express this ruleset
If the request is /hello then try the following in the given order:
/hello — File of that name exists (file without file extension).
Edit: Not a necessity. Only a ...
0
votes
2
answers
409
views
HTTP 403 with CloudFlare
I've added my site to CloudFlare. I'm trying to allow requests to only come in through CloudFlare's network, and reject all others. When I add the following to my .htaccess, I get HTTP 403 Forbidden.
#...
1
vote
3
answers
169
views
Apache: How to "hide" a subdomain but serve over https
I will freely admit my ignorance - or perhaps enough knowledge to be dangerous.
I have a subdomain http://db.<mydomain>.com that serves the phpMyAdmin utility. It's currently in a directory with ...
1
vote
1
answer
425
views
Apache mod_rewrite RewriteRule loops despite L flag
Apache/2.4.54.
I am trying to achieve that similar URLs (e.g. "/anystuff.htm") are externally redirected to "/something" which internally is "something.html".
But the ...
1
vote
0
answers
13
views
Setup Authentication for landingpage fetching data from proxy via access restriction?
Imagine the scenario where you have a client who wants you to implement calls to an external API on a landingpage that you've setup for them. The external API works based on a contract and API keys ...
0
votes
0
answers
683
views
Want to redirect URL and change slug to url parameter
I am stuck with a mod rewriting on Apache htaccess.
my URL looks like this :
http://localhost/Ac5GRnXW
I want it to redirect like this:
http://localhost/redirect.php?id=Ac5GRnXW
I am using the ...
1
vote
1
answer
85
views
htaccess syntax issue when moving script to a subfolder
I have recently purchased a script but this script only works in public_html folder . I need to install it in a subfolder named shop ( public_html/shop/ ) . Now the following .htaccess rules work ...
1
vote
1
answer
3k
views
htaccess, block access a url with parameters
If I want to block access to example.com/path/?xxxx (xxxx is variable), but allow access to example.com/path/, how should I write it in my .htaccess?
1
vote
1
answer
797
views
Condition depending on domain in .htaccess: SetEnvIf and IfDefine?
I would like to add a rule in .htaccess that "Does something" (actually enable a httpauth user restriction) depending on the domain name.
I thought I had it and did:
<IfModule ...
0
votes
1
answer
168
views
Block IP adresses via htaccess without possible override
I have blocked some IP addresses within the .htaccess of my webpages root like this:
<RequireAll>
Require all granted
Require not ip xxx.xxx.xxx.xx
</RequireAll>
I also use some plugins ...
0
votes
0
answers
72
views
Wordpress crashes Internal Redirect
I am trying to find the issue why my Wordpress installation makes a 10 times redirection and crashes the session. The hint that I am getting from the Apache logs is:
[perdir /usr/www/users/server/...
1
vote
0
answers
115
views
when it goes to https:/... directly it is missing the referer part
it's all about cookies ,it suppose redirect to ?referer_id=186 every time which is refresh the cookies of new logo but i notices when user delete or clear the history of Brower and try to visit the ...
0
votes
0
answers
174
views
$_POST is empty when obtaining in "ErrorDocument 404" (nginx + apache + mod_php)
I try to transfer website from old server to new, and stucked with one problem. PHP/JS code on both servers is the same, but on new server it is not working - $_POST data are empty in AJAX-request.
...
0
votes
0
answers
39
views
apache mod_rewrite path to querystring - keep base directory
I try to "beautify" my URLs from eg. www.example.com/page.php&id=3 to www.example.com/page/3
I can achieve this with:
RewriteEngine On
RewriteRule ^(page)/([0-9]+)$ page.php?id=$2
The ...
2
votes
1
answer
357
views
Apache .htaccess if doesn't work with local assigned env vars
I want to set an env var in .htaccess file. The first line is changed by a script whenever the site is set to maintenance mode.
# maintenance mode on/off
SetEnvIf maintenance 0
<If "env('...
0
votes
1
answer
2k
views
Remove both index.php and file extension on other php pages using .htaccess
I would like to remove the need to include index.php in my links. Instead of
example.com/about/index.php
I would like it to be
example.com/about/
Secondly, I would also like other non-index pages to ...
1
vote
1
answer
208
views
On Apache how to switch off DirectorySlash only for requests to a specific subdomain?
Served by Apache I'd like on one subdomain site of mine (say sub.mydomain.com) that URLs without trailing slashes point directly (without external redirect) to the index file in the underlying folder. ...
1
vote
1
answer
406
views
Apache: <LimitExcept POST> not working (in .htaccess)
I am trying to set some controls in Apache via the .htaccess. This works:
<LimitExcept GET>
Order allow,deny
Allow from all
Deny from all
</LimitExcept>
while this does not:
&...
1
vote
1
answer
947
views
Apache 2.4 .htaccess Set Headers for error pages
I am setting some headers using .htaccess for a web page, f. e.:
<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>
...
0
votes
1
answer
406
views
How to make only "/var/www/html/login" public on my apache2.4 server?
I need some help please.
I'm using apache2.4 on my server. I'm blocking all requests to / using the following code:
<Location />
Deny from all
AuthUserFile /path/.pass
...
0
votes
0
answers
160
views
Language based RewriteRule like mysite.com/en/ in .htaccess
I'm trying to write redirect directives in the .htaccess to forward internally all user requests like this:
Every request in a language folder should redirect to the requested file with the language ...
0
votes
2
answers
344
views
trying to redirect in .htaccess unless it's an admin
I am trying to write a rule in .htaccess that redirects all /wp-admin to /login UNLESS a certain user (WebAdministrator) is logging in. How do I make such a rule?
If I use:
Rewriterule ^wp-admin /...
1
vote
1
answer
255
views
Apache .htaccess causing images to load extremely slowly
I am running a single page application that requires the following lines on my .htaccess . However, images on its /images/ folder are now loading extremely slowly.
Is there anything wrong with the ...
0
votes
1
answer
471
views
Apache: Allow Certain Users only from specified subnet
I have a requirement to change some Apache 2.4 authentication so that most users can access the website from anywhere, but certain users (who can be identified in a number of ways, but an LDAP group ...
1
vote
1
answer
989
views
Apache .htaccess require ip not strict enough with IPv6
Let's suppose my IPv6 is 1111:2222:3333:4444:5555:6666:7777:8888
I can write any of these lines in the Apache .htaccess:
Require ip 1111:2222:3333:4444:0000:0000:0000:0000
Require ip 1111:2222:3333:...
1
vote
1
answer
718
views
ProxyPass and ProxyPassReverse causing 500 error on server
We have the following:
WordPress static website at https://www.domain1.com.
React/Django Web application at https://www.domain2.com with three main URIs:
/
/admin
/api
We would like them to appear ...
1
vote
1
answer
679
views
How allow a set of IPs and deny everything else? (.htaccess and apache 2.4)
I need allow internet access from a set of IPs and deny everything else.
How can I do that?
I tried this:
<RequireAll>
Require all denied
Require ip x.x.x.x/xx y.y.y.y/yy
</RequireAll>
...