All Questions
135
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 ...
1
vote
1
answer
41
views
.htaccess to accept parameters in URL
I have a WordPress page with the following structure website.com.au/pre-registration/parameter-value/, where the parameter value was originally a GET parameter, but I was requested to make it part of ...
3
votes
1
answer
411
views
How to match beginning of file name using htaccess
I am attempting to modifying my .htaccess file within a specific directory. If a web user attempts to find any file in this directory that may be named like the following options, I want them to be ...
1
vote
1
answer
182
views
Creating a .htaccess in a subdirectory causes rewrite rules in higher level .htaccess to stop working
Sorry if this has been asked/answered before, but I was not able to find an answer to this particular problem.
If I create a .htaccess file with a simple rewrite rule, that rule works. If I create ...
1
vote
2
answers
467
views
Apache Rewrite Engine redirect all request to index.php
I have a PHP web application on a Apache Web Server.
The path to to web application on the Server is: /var/www/html/intern/organisation/example_app
The URL to the web application is:
https://www....
0
votes
0
answers
48
views
Why does this directory rewrite only work for top-level content, not subdirectories?
I have the following lines in my .htaccess file:
RewriteCond "%{DOCUMENT_ROOT}/_legacy/%{REQUEST_URI}" -f
RewriteRule "^(.+)" "%{DOCUMENT_ROOT}/_legacy/$1" [L]
...
1
vote
1
answer
165
views
Edit .htaccess file to make file accessible
I was trying to make a WordPress plugin work, when I found, after hours of debugging, trial, errors and praying ancient Greek gods, that the plugin did not work because it was impossible for the ...
2
votes
1
answer
368
views
.htaccess return error if no RewriteRule meets the request
I'm trying my hands on writing a simple REST API and am currently trying to properly configure my .htaccess file.
What I'd like to achieve is the following:
have RewriteRules to direct requests ...
1
vote
0
answers
93
views
Apache2: mod_ratelimit only allowing half the speed
I'm trying to limit the file download speed in a directory
I've got the following .htaccess
<IfModule ratelimit_module>
SetOutputFilter RATE_LIMIT
SetEnv rate-limit 4096
</IfModule>...
1
vote
1
answer
882
views
Redirect all URLs ending in ".-detail" to remove the dot
I have a rather odd situation where our old URLs are ending in .-detail and need changing to just -detail.
For example:
example.com/product.-detail needs changing to example.com/product-detail
In ...
-1
votes
1
answer
61
views
I'm in trouble with .htaccess RewriteRule
I'm trying make to a social platform like Instagram or Facebook and I wanna to show users, username like that examplesite.com/usernamehere so in the url. I'd been researching how to do this and I ...
1
vote
1
answer
187
views
How Can We Do 301 Redirect Of Over 200 Pages To Corresponding 200 Pages At New Location?
I need help and need it fast.
We recently migrated a subdomain to integrate with the domain.
Eg. https://blog.example.com to https://www.example.com/blog
https://blog.example.com has a ton of traffic ...
2
votes
1
answer
2k
views
Redirect part of a URL parameter to the URL-Path
I used a module that created links like this:
https://example.com/login?create_account=1&back=https://example.com/product/2164/?ets_rv_add_review=1
I need to redirect them to:
https://example.com/...
1
vote
1
answer
368
views
.htaccess redirect if param value not portuguese-pt (FORCE WHMCS ONLY ONE LANG)
I need help to redirect URLs with multiple language codes to one with .htaccess. The following URLs should redirect:
https://example.com/cp/cart.php?a=add&pid=7&language=us
https://example....
1
vote
0
answers
22
views
Redirect docroot for specific URI path by .htacess
Is it possible to redirect a specific URI path to a specific docroot within the original docroot using the .htaccess?
For example:
example.com > docroot
Where
example.com/path > docroot/subdir
1
vote
0
answers
377
views
Automatically remove Set-Cookies
I have a php web application. This web application sets some cookies.
I want to write a .htaccess which remove on the fly this cookies.
Here is what I've done, with mod_header:
Header unset Set-Cookie
...
3
votes
2
answers
1k
views
SEO friendly URL not working
I have a folder structure like the below www.exampe.com/distributor/index.php
and I want to access the file via an SEO friendly www.example.com/distributer/abcinc
and then in the index.php want to ...
0
votes
0
answers
989
views
.htaccess deny access to subdirectories from a certain domain
I have a server with a security flaw:
There's the main site https://example.com (on server /var/www folder)
Then there's an additional app (on server /var/www/app/public) that is configured to be on ...
3
votes
2
answers
6k
views
Redirect to other server and domain if file not found
I have migrated from Apache to Nginx so I want to set all rules in Nginx.
Goal: Redirect a URL to another domain with the same filename if that file is not found on the requested server.
Example
If a ...
2
votes
2
answers
7k
views
.htaccess redirect sub-folders to the correspondent index.php
How can I redirect each request for a subfolder to the index.php in the same folder
myserver.com/folder/subfolder1/test redirected to folder/subfolder1/index.php
myserver.com/folder/subfolder2/...
0
votes
1
answer
931
views
Redirect all pages to non www and one page to www
I want to redirect all my internal pages (eg: example.com/about) to their non-www version but I want my homepage (https://example.com) to redirect to its www version (https://www.example.com).
I ...
0
votes
0
answers
29
views
masking URL after redirection [duplicate]
I re-post my question in the event that I will be more clear as to what I would like to do.
I have a subdomain under a dns name, lets say it is mysub.domain . This subdomain is in a remote provider ...
0
votes
1
answer
1k
views
Block `//xmlrpc.php`
I'm getting tens of thousands of (quite probably malicious) hits on Apache which are bringing the server down. All hits look like this on the Apache log:
[30/Jan/2022:21:57:41 +0000] "POST //...
1
vote
1
answer
736
views
How to make mod_rewrite force a redirect?
I have a need to temporarily redirect my website to a static version hosted on Cloudflare. The current site is a Wordpress site hosted at Ionos and Wordpress seems to be doing a 301 redirect from ...
0
votes
1
answer
582
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 ...
0
votes
1
answer
487
views
htaccess match all words until last slash and redirect 301
I'm trying to escape everything until the last slash, even if there's a slash in between.
Example:
/site_url/courses/cat1/cat2/subcat/coursename
to
/site_url/course/courseName
or
/site_url/course/...
6
votes
2
answers
7k
views
.htaccess - Exclude folder from basic auth protection
I have a website where no one is allowed to enter without entering the basic auth credentials.
However, I need the media folder to be accessible by everyone, because we are using a third party ...
-1
votes
1
answer
716
views
How to fix domain redirect with slash using Apache2 and Bitnami?
I'm running a Wordpress website with Bitnami which confused me a lot of ways.
The issue is when you click a link www.domain.com/ja/ then it goes to www.domain.comja because there is a missing slash /
...
3
votes
2
answers
7k
views
Apache Options -Indexes for sub directories
Per How can I prevent people from looking at a listing of files in parent directory if I haven't uploaded index.html? I can see how to disable listing of files if there is no index.* file.
How can ...
0
votes
2
answers
811
views
Multiple Conditional redirects all in a single .htaccess (Landing Page)
I have a folder that simply has a "Coming Soon" single page html.
I then have several domains that I point to this folder from time to time as needed.
Simple right?
Well what I want to have ...
0
votes
2
answers
619
views
How to block potential attackers on my server
To keep it brief and simple, I will go straight to the point. It seems a bunch of ip adresses are trying to access files that have potential of containing sensitive server information on my website ...
1
vote
1
answer
81
views
How to load requested file from sub-directory without rewriting base
Utilizing .htaccess rules, I'm attempting to load a file from within a sub-directory while keeping the frontend URL unchanged if both the domain and file path match criteria.
Example of URL:
example....
4
votes
1
answer
2k
views
htaccess rewrite /dir/*.jpg to /dir/webp/*.webp only when webp file exists
I'm trying to rewrite all website files (*.jpg|*.gif|*.png) to *.webp in a subdir, but only when the *.webp file exists. Previous and new files have the same name, only changing the extension and *....
2
votes
1
answer
1k
views
Apache with HTTP/2 and per-directory upload_max_filesize
I just upgraded my apache2 server on Debian 9.13 Stretch to start using HTTP/2. As far as I'm concerned, that requires switching from mod_php to PHP-FPM.
The problem is that PHP-FPM does not obey ...
1
vote
1
answer
482
views
After installing script all subdomains go to the main domain
I have a main domain www.example.com.
and the following subdomains under the main domain
support.example.com
test.example.com
Previously both subdomains are working fine.
But after installing a PHP ...
1
vote
1
answer
92
views
2 websites hosted on same domain, 1 needs to look like a subfolder ( /blog)
I bought a VPS for my new project running apache.
On it I have 2 websites on the same domain.
The first one is Ruby on Rails /var/www/html
The second one is Wordpress /var/www/blog
I want Wordpress to ...
0
votes
1
answer
73
views
How to redirect search.php?query=test&search=1&s=1 to /query/test
I have tried other things, but I cannnot get it to work, when I go to the main website, (index.php is just a include of search.php) it will send me to this /query/search.php/search.php/search.php/...
0
votes
2
answers
5k
views
Apache .htaccess set a header if Request URI does not exactly match a desired value
Goal: using a .htaccess file in /directory/, if request URI does NOT exactly match "/directory/" then set a header. For example, the header SHOULD be set if the request URI is "/...
1
vote
1
answer
3k
views
Issues with Require IP on Apache 2.4 and Ubuntu 20.04 server
I have setup a subdomain (staging.callkneehill.ca) on my server and have created a .htaccess file with the following parameters:
<RequireAny>
Require ip 70.65.194.109
</RequireAny>
...
2
votes
1
answer
896
views
How to get line number of error that .htaccess apache2 is reporting in /var/logs/error.log
I get a internal server error after adding redirects to .htaccess - I've added 600 of them.
I check /var/logs/error.log
[Wed May 12 16:26:02.600394 2021] [core:alert] [pid 8071] [client 127.127.127....
1
vote
1
answer
3k
views
Apache Do Action Only If Path Contains
I'm using the following in an .htaccess to remove the extension from .php files:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
It works great, but how can ...
1
vote
1
answer
147
views
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 ...
0
votes
3
answers
4k
views
How to tell .htaccess to only allow requests to index.php and app/dist/* folder?
This is the current folder:
/app
/dist
/index.html
/index.css
/index.js
/src
/configurations.json
/index.php
/configurations.php
I have sensitive data everywhere:
app/src/...
/......
2
votes
2
answers
443
views
Can't serve static files with ampersand in name
I have a website mirrored with wget and I'd like to serve it via Apache. The problem is that I can't access files with special chars. For example, I have files with names like this:
$ ls -N components/...
4
votes
1
answer
998
views
Improving apache2 security
I have been analyzing my server logs for a week and I found bad intentioned requests, and I want to know if is possible to protect it, because I have no clue about what I should to, the only idea I ...
0
votes
1
answer
442
views
Migrating from Apache to NGINX - config change
I am tring to migrate a legacy website from Apache to Nginx, but I can't rewrite the htaccess file to nginx config.
Current htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
Options +...
1
vote
1
answer
682
views
Apache Reverse Proxy : put a htaccess type password on a specfic URL
I have an Apache2 reverse proxy managing multiple domains.
Inside I have a vHost configured like this :
<VirtualHost *:443>
RewriteEngine On
ServerName www.example.com
...
1
vote
1
answer
3k
views
Apache ErrorLog: cannot use a full URL in a 401 ErrorDocument directive --- ignoring
I use the .htaccess file on my Apache to display custom error documents. This all works fine too.
But I still see lots of this error in the log:
[Thu Aug 13 10:38:31 2020] [notice] [client AH00113: /...
0
votes
3
answers
3k
views
How can I return 404 for specified existing file in apache and nginx?
I need to return 404 error for some specified files like 'config.php' . How can I do it with '.htaccess' in Apache? And in nginx without htaccess? Thanks.
0
votes
1
answer
294
views
Two sites on the same server with unwanted redirection
I have two different sites
domain1.com
domain2.com
Problem : I only can access domain2.com by using www.domain2.com
If i try domain2.com it redirects to domain1.com.
Configuration files:
domain1....