All Questions
Tagged with apache-2.4 .htaccess
391
questions
-1
votes
0
answers
10
views
if statement in htaccess
I'm using the following .htaccess to allow access to my website by IP address:
<Limit GET POST>
Require all denied
Require ip x.x.x.x
Require ip y.y.y.y
</Limit>
I was wondering if it ...
0
votes
0
answers
48
views
Using environment variables and a redirect loop to force-clear a 301 redirect
We mistakenly used a 301 redirect on a very important page, and now that we want to actually use the page, many users' browsers have the 301 stuck in their cache. The problem is that the destination ...
0
votes
1
answer
77
views
.htaccess to get the list of ip from a file or directories of file
I'm blocking certain spammers/bots from accessing my website via IP addresses, but I have around 3 directories (/var/www/directory1, /var/www/directory2, /var/www/directory3).
Every time I want to ...
1
vote
1
answer
207
views
.htaccess to normalize requests to files with or without extension to URL without extension: $1(\.html?) --> $1
This is a followup question
My intended .htaccess ruleset has overall been achieved.
See that file in its current form quoted below.
Remaining problem: One ruleset yet not working
Goal: Normalize ...
1
vote
2
answers
513
views
.htaccess files directive only matching when I'm checking the same folder
I've got a server set up where I want a specific PHP file to be readable via the browser, but I want access to be denied to the rest of the PHP files. So I put this .htaccess in the server root:
<...
0
votes
0
answers
548
views
htaccess to stop Host Header Injection
I have one application hosted on XAMPP, my application url is https://abc.example.com/pps/prd/, i have htaccess file at pps/prd/, with following code to stop Host header injection
RewriteEngine On
...
0
votes
1
answer
51
views
Content negotiation, send webp request to Symfony when webp file does not exist
On Apache Httpd 2.4, I know that from a .htaccess file I can do this
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.jpg$ $1.webp [T=image/webp]
in ...
0
votes
2
answers
470
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
50
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
44
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
2
answers
760
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
1k
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
1k
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
108
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
491
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
329
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
73
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
2
answers
479
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
1k
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
214
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
647
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
419
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
491
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
197
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
110
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
316
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
151
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
83
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
507
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
497
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
531
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
242
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
549
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
15
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
881
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
102
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
4k
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
1k
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
241
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
85
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
170
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
265
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
58
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
472
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
3k
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
299
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
548
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
1k
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
455
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
164
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 ...