33,146 questions
0
votes
0
answers
43
views
PHP-FPM and Apache - setting SCRIPT_NAME
So far as I can tell, a simple installation of Apache and PHP-FPM (the versions supplied in the Debian 12 repository) results in different values for $_SERVER['SCRIPT_NAME'] from when Apache mod_php ...
0
votes
0
answers
15
views
.htaccess Hotlink prevention not working with [F], works with /403.html
I was trying to implement hotlink prevention on my site using .htaccess, but I encountered some issues.
I first tried this rule:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(...
0
votes
1
answer
41
views
Permission denied: AH00529: /home/username/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
I'm seeing a lot of errors in apache error log:
(13)Permission denied: [client xyz:63932] AH00529:
/home/username/public_html/.htaccess pcfg_openfile: unable to check
htaccess file, ensure it is ...
0
votes
2
answers
32
views
.Htaccess Customize Query String
I am using the code below.
RewriteCond %{QUERY_STRING} ^brands=(.*)&features=(.*)$
RewriteRule ^products/([_A-Za-z0-9-]+)$ index.php?brands=%1&features=%2
However, this requires both values. ...
0
votes
0
answers
40
views
unexpected behavior in .htaccess when redirecting directory paths to a .php script
I'm working on a website template.
The idea is to have the following base directory structure:
template // template-only files, don't modify!
private // for internal usage
public // for ...
0
votes
1
answer
20
views
Apache rewrite - append the request to a script
I want to append the request to a script.
example.com -> example.com/d.php
example.com/css/style.css -> example.com/d.php/css/style.css
example.com/api/ShowPdf?bar=Foo -...
0
votes
1
answer
20
views
Require minimal length of key in query params with .htaccess
The keys of query params of URLs should have a minimal length, e.g. 6 characters, to be accepted. This should be filtered by .htaccess.
Example of URL being ok:
https://example.com/blogs/?...
1
vote
0
answers
23
views
apache 2.4, mod_rewite, htaccess: RewriteRule in <IF>
Got an inherited problem from a retired admin. We have a 1900+ line .htaccess and I have to consolidate as a first step.
Instead of writing 700 times
RewriteCond
RewriteRule
I'd like to group the ...
2
votes
1
answer
26
views
How to Set a RewriteRule Based on RewriteMap Lookup in Apache?
I’m trying to create a rewrite rule in Apache to match URLs not matching a specific value retrieved from a RewriteMap.
I have a RewriteMap defined as follows:
RewriteMap product_map txt:/path/to/...
0
votes
2
answers
64
views
.htaccess URL Rewrite Rule Not Working In Subdirectory of Existing WordPress Site on Apache
I am trying to get a redirect rule working in a subfolder so I can rewrite a URL from:
https://www.somesite.co.uk/api/FormEntries.php?id=1
To (which is how users would access the above to provide a ...
0
votes
0
answers
14
views
seo friendly url rewriting with multiple parameters
I have a database full of physical locations along with their address information and want to use SEO friendly urls.
I'd like to turn this :
example.com/locations/?state=California&city=Los+...
0
votes
0
answers
8
views
Apache: returning error based on existence of a file named in a query string
I have a page which is returned by https://myserver.com/login?z=XXXXXX
XXXXXX is a 6-character string such as ABC123.
I would like Apache to return an 403: Forbidden error response if file
%{...
0
votes
0
answers
38
views
How to block user agents using a RewriteMap?
I'm trying to create an Apache RewriteMap for user agents, but I'm stuck. This code works fine if the agent is a single word and matches the agent string exactly:
RewriteMap agent_map "txt:/...
0
votes
0
answers
37
views
Bulk redirect Wordpress website URLs without redirect chain
I have a multilingual website in WordPress. It has IT and EN versions, and I want to change its default language to EN.
For SEO, I want to redirect all of the old URLs to new ones:
site.com/* to site....
0
votes
1
answer
36
views
My .htaccess file's redirect for URL query trails does not appear to work
Good day, I would like my site to direct trailing queries in the URL to a simple "/".
For example: "https://www.website.com/page?url_query=my-article" to "https://www.website....
0
votes
0
answers
39
views
Unable To Serve Webp Images Through htaccess
I'm having problem to serve webp format images through htaccess. I have followed https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website and https:...
2
votes
1
answer
70
views
How to write a clean URL with mod_rewrite using virtual dirs, actual dirs and variables as a combination
I have read prior questions and read tutorials and I do not understand mod_rewrite fully so I am posting here. My current .htaccess is:
Options +FollowSymLinks
RewriteEngine On
#### 1st set of rules....
1
vote
1
answer
84
views
.htaccess trying to create Clean URLs mod_rewrite
I have read prior SO questions and read tutorials and I do not understand mod_rewrite fully so I am posting here
Options +FollowSymLinks
RewriteEngine On
#Using THE_REQUEST for catching references ...
0
votes
0
answers
9
views
Mod rewrite NC,L,QSA for SEO?
I just got mod_rewrite working. In my .htaccess file I put in the code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [...
0
votes
0
answers
12
views
mod rewrite for removing ? from the url
Am using apache2, I require to remove the question mark from my url. For example if my url http://192.168.20.120/docs/pay/?2023/04/text.pdf I need to remove ? and result http://192.168.20.120/docs/pay/...
-1
votes
1
answer
52
views
How to make htaccess code work with parameters
Hi all
I am editing a htaccess file
My url is is cricf.com cricket-article?cardid=3730
I use the code below for rewriting the URL
RewriteEngine on
RewriteCond %{THE_REQUEST} cricket-article.php
...
0
votes
0
answers
39
views
Do I need to use REGEX/URL rewriting for my BeEF / Nginx reverse proxy config?
I am running BeEF on an Nginx Virtual Server, behind Nginx which is acting as a reverse proxy. Furthermore, the webpage which the BeEF hook will sit on is also on a separate virtual server, also ...
1
vote
0
answers
37
views
Using mod_rewrite to redirect all requests to another directory
This should be easy but apparently isn't.
My http.conf points mydomain.com to "/var/html/www".
In "/var/html/www" is a folder called "production" that contains another ...
0
votes
0
answers
15
views
mod_rewrite question for many virtual directories -most efficient code?
My current .htaccess is:
RewriteEngine On
#Using THE_REQUEST for catching references and using them later on.
RewriteCond %{THE_REQUEST} \s/(content)/index\.php\?var=(.*?)\s [NC]
RewriteRule ^ /%...
2
votes
1
answer
94
views
.htaccess assistance with rewrite rule
I have trouble rewriting virtual directories as variables.. can someone help please?
The URL is:
https://www.example.com/content/index.php?var=1-dKein4i59xcNjfks
I want it to look like:
https://www....
0
votes
0
answers
52
views
Reverse proxy for a streamlit app with apache2 under a subdirectory
I am running a streamlit app on a dedicated server on the internet. The app runs on port 8501.
I have setup a reverse proxy with apache2 to redirect the traffic to port 8501. I also have https and a ...
2
votes
1
answer
43
views
Block specific regex in htaccess
There is a way to block all the requests with a certain querystring?
GET /?7eyS=cUYD HTTP/2
GET /?8dkG=TMWZ HTTP/2
GET /?viYF=4KbU HTTP/2
GET /?Wv3y=oCSA HTTP/2
2
votes
2
answers
60
views
Rewrite rule to resolve 2 use cases
I have a rewrite rule in my .htaccess file:
RewriteRule ^projects/?([a-zA-Z0-9-]+)?/?([a-zA-Z0-9-]+)?$ /projects/$1/seo.$2.php
For example, the following rule works fine and I would like to keep it ...
0
votes
0
answers
29
views
Unexpected behaviour rewriting path to parameter using upon trailing slash htaccess mod_rewrite request_filename
I came across an unexpected behaviour rewriting the first (and second) folders of a nice-URL into parameter to be handled by PHP. As example "https://server.net/test2/" in the browser ...
1
vote
1
answer
83
views
Apache rewrite condition - directory check not working for trailing slash
Within our virtual host config, I am trying to use a RewriteCond to check if a trailing slash request is requesting a .html page that exists on our website. If so, 302 redirect it to the proper .html ...
1
vote
1
answer
54
views
How to Allow Access to Only Specific URLs and Rewrite Them Using Apache .htaccess?
I'm working with Apache and want to use .htaccess to achieve the following:
Rewrite /api/get to get.php
Rewrite /api/report to report.php
Only allow access to these URLs/scripts
Essentially, I want ...
1
vote
1
answer
56
views
.htaccess 301 rewrite rules for wildcard automated rewrite rules
Can someone help me with doing a 1 line rewrite rule so that I don't have to do 1 by 1 for article urls
example of old URL:
olddomain.com/article/12/name-of-the-old-page.html
which I just want to ...
0
votes
0
answers
19
views
Is it valid, to write RewriteCond and RewriteRule in the same line?
I have multiple (very much) redirect rules for a site relaunch. I foster them in an Excel table.
Is it valid, to write RewriteCond and RewriteRule in a .htaccess with any other separator, than a new ...
0
votes
1
answer
37
views
htaccess rewrite rule 401
I have this inserted in my htaccess file on a WordPress installation
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
I am using LSCWP and I want to try the guest mode.
For that I need access to ...
0
votes
0
answers
38
views
How to capture ProxyPassMatch response?
I have an apache proxy server setup that acts as a router between my multiple backends. The httpd.conf file is something like this
ProxyPassMatch "something/([^/]*)/(.*)" "http://$1/$2&...
0
votes
0
answers
47
views
how to use Apache LocationMatch *after* RewriteRule with QUERY_STRING
I'm using ProxyPass for two URLs (A and B below) that both include a question mark and the string 850: -
A: https://frontend.com/850/home?session=25575 -> https://backend.com/850/home?session=25575
...
-1
votes
1
answer
48
views
.htaccess virtual directory as a $_GET parameter
While working with multiple databases I have a database ID stored in $_SESSION and I would like to pass that ID within the url instead, as such:
Now: my.domain.app/hrm/employees
New: my.domain.app/...
1
vote
1
answer
55
views
I call the PHP file in the subfolder, but the .htaccess uses a weird rewrite
In the root I have files: .htaccess and page.php
In the /test/ subfolder I have files: define_session.php and write_session.php
.htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{...
1
vote
1
answer
39
views
.htaccess rule to implement root and subfolder in same way
we have a directory in which there is a index.php file, for which we have defined rule via .htaccess which is working fine, now we need to create a subdirectoy that will also have index.php file.
Now ...
0
votes
0
answers
29
views
Avoiding double redirects by .htaccess
By using the following .htaccess section I make sure that every URL is redirected to its https://www. version:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [...
0
votes
1
answer
40
views
.htacess unable to remove www from specific URLs
I have the following .htacess file:
RewriteEngine On
RewriteBase /
# Remove 'www' from the URL
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Redirect ...
0
votes
0
answers
87
views
Redirect HTTP traffic to HTTPs on same port in Apache reverse proxy
I've got a reverse proxy operating on port 2000 using Apache.
It's listening to another web server on the same port which is broadcasting HTTP.
I can get the reverse proxy functioning fine, and HTTPS ...
0
votes
0
answers
133
views
Rewriting URLs using .htaccess in cloudflare pages (can it be done with headers?)
edit: Maybe htaccess does not work on cloudflare pages in the first place. I know cloudflare pages has redirects (changes the URL for the client) and headers
Can it be done with headers? (if htaccess ...
0
votes
1
answer
36
views
Downloading Static Files via Apache-deployed Angular app
I have an Angular 15 webapp, deployed on Apache/2.4.53, on a CentOS server.
I have used Rewrite rules to redirect all requests for my app to the index.html, so that Angular can handle the routing ...
0
votes
1
answer
49
views
Apache config: RewriteRule in <If> block never rewrites
I'm customizing the configuration of Apache httpd (2.4.59). Here is one puzzle:
This rule rewrites matching URIs if unconditional:
RewriteRule ^/abc/.* /myscript.php [L]
But if coded this way, the ...
0
votes
1
answer
41
views
mod_rewrite: Error 500 triggered when URI contains an existing file without extension followed by /whatever when using REQUEST_FILENAME
What I want to do
If the requested resource in the URL has no extension and a file name matches the resource, use mod_rewrite to service that file. Otherwise, trigger error 404.
E.g. request is /foo ...
0
votes
0
answers
33
views
Mirroring pkgs.tailscale.com with nginx fails, mirroring tailscale.com works
I am trying to mirror/reverse-proxy the package server pkgs.tailscale.com because that server is blocked at some locations.
For some reason I can easily mirror the regular tailscale.com website with ...
0
votes
0
answers
37
views
How to redirect all query string URLs of this type
I can't direct links followed by queries in PHP calls I would like to direct only some PHP pages
I have urls that call certain php pages and are followed by query strings,
https://hello.it/tr/wp-admin/...
0
votes
1
answer
21
views
Can't get RewriteCond right in .htaccess
I'm trying to redirect some urls, but RewriteCond is not working. What am I doing wrong?
URLs I try to redirect:
https://kotrabatowy.pl/kod-rabatowy/*/test1
https://kotrabatowy.pl/kod-rabatowy/*/test2
...
0
votes
0
answers
11
views
Apache 2.4 conditional doesn't match regexp
I'm trying to match a simple condition in apache virtual host to rewrite the original URL and redirect to the load balancer definition.
The condition should match against URL like
"https://...