Questions tagged [mod-rewrite]

URL rewriting module for Apache web servers

Filter by
Sorted by
Tagged with
3
votes
3answers
352 views

Apache: Return static string for location

For a .well-known path, I want to return a static JSON file/string. With nginx, this seems to be possible without creating that file by specifying the content in the configuration file: location /....
-1
votes
1answer
19 views

Modify Apache rewrite rule for Nginx

How to rewrite this Apache rewrite rule for Nginx? RewriteCond %{REQUEST_URI} ^/api RewriteRule (.*) index.php [L] I tried this but it doesn't work, I'm getting HTTP 404 in /var/log/nginx/access....
1
vote
1answer
23 views

Redirect the document root and a specific page only to another domain

Might sound confusing, but what I want to achieve is this: If the user visits: www.mydomain.com (with or without www.) transfer them to: www.myotherdomain.com/welcome-old-users At the same time, I ...
3
votes
1answer
74 views

Apache: Don't log errors for certain non-existing files (regular file or symbolic link)

I want to prevent Apache from logging "File does not exist" errors for certain irrelevant non-existing files that are often requested, such as "apple-touch-icon-120x120.png". These ...
0
votes
1answer
69 views

Forwarding Apache SSL-Port to Web-App on localhost

I'm struggeling for days now to route a subdomain with SSL to a local running vue app, specifically the directus admin ui. I've done this before, like with the tool monit, and it worked like a charm: &...
0
votes
0answers
77 views

Application alias rewrite using apache

I am new to apache and i am trying to rewrite an application default alias to a more elegant one using apache but unfortunately i struggle and i can't find a way to do it Can you help me please ? What ...
1
vote
1answer
57 views

Apache rewrite causes server error 403 when genuine directory exists after extension removal rewrite

I've spent a couple of days now trying to create a specific rule set that will allow me to remove .html extensions from all the files in the directory and present neater URIs. I'm using a .htaccess ...
1
vote
1answer
94 views

Rewrite instead of redirect with Azure Web App/Linux

I'm trying to configure rewrite rules with .htaccess on an Azure Web App with Linux+Apache(+PHP), however I can only get redirects to work (but no rewrites). The source is structured as following: ./....
1
vote
1answer
11 views

Space in value part of RewriteMap

This question is related to Apache RewriteMap with URLs containing space doesn't work, but in this case the issue is a space in the value part of the map, not the key part. Say I have this entry: /...
0
votes
2answers
65 views

Mod-rewrite Port in Apache2

I'm playing with home assistant (HA) in docker on Ubuntu 20.04. HA is hosted on port 8123. HA does not support subpaths, ie. it is hosted at MYDOMAIN.duckdns.org:8123 rather than MYDOMAIN.duckdns.org:...
1
vote
1answer
36 views

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 ...
0
votes
1answer
42 views

How can I apply some apache directives based on the original URL before rewrites?

General Question: Apache allows you to place directives within a <Location> section in order to apply them selectively based on the request path. There is also mod-rewrite, which allows you to ...
1
vote
1answer
26 views

Apache Rewrite Whirlwind

I have inherited an environment where they used a re-write rule to redirect 1400+ clients with HTTPD/Apache. I am looking to add a subdomain for development (so a multi level subdomain) and I am ...
0
votes
1answer
21 views

How to erase “about:blank” from URL with a RewriteRule?

Want to delete the about:blank from a URL www.example.com/camera/about:blank. How can I do this with .htaccess? I tried RewriteCond %{QUERY_STRING} (about:blank) [NC] but it didn't work.
0
votes
0answers
46 views

How can we capture the REQUEST_URI into an Apache variable and after third party SSO authentication?

How can we capture the REQUEST_URI into an Apache variable and after third party SSO authentication? We have a third party SSO authentication in place, which is working fine. After successful ...
1
vote
0answers
77 views

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 ...
2
votes
1answer
69 views

Apache rewrite rules don't work after excluding directory from authentication

I want the content of a directory "dir" protected, but if the user accesses the directory itself, I want a PHP file from the parent directory served instead. This works with the following ...
1
vote
1answer
28 views

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 ...
2
votes
1answer
99 views

.htaccess redirect/rewrite many domains to many domains

My idea is: requests to service.example.com should be redirected to service.example.com, all the other requests to example.com should be redirected to base.example.com My host is configured in such ...
1
vote
1answer
64 views

Apache ProxyPass + RewriteRule?

I've set up an apache config to try to redirect /login and to ProxyPass all other requests: RewriteEngine on RewriteCond "%{REQUEST_URI}" "^/login$" RewriteRule "^/login$"...
2
votes
1answer
41 views

Apache rewrite proxy only homepage

I've tried various regular expressions (^/$, ^index.php$, ^$) to rewrite/proxy just the homepage of a WordPress website through .htaccess. For the record I have the appropriate modules loaded to ...
0
votes
2answers
117 views

RewriteRule conflict and trailing slash

We are migrating a website to our cPanel infrastructure. The customer hosted the website on his own infrastructure using Nginx. He sent to us his Nginx configuration files and we converted them to ...
1
vote
1answer
52 views

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 ...
1
vote
1answer
75 views

Htacess Helicon APE false positive 403 Fail

Instead of using web.config for my rewrite rules, I have been using Helicon APE for emulating Apache's .htaccess feature. I have a large universal .htaccess file that is applied across the server as ...
1
vote
1answer
67 views

Apache - redirect without changing URL in user's browser

Is there a way to redirect with mod_rewrite without changing the URL in the user's browser? I saw a solution using [P] in the end of RewriteRule, but this is not working for me. What I want: https://...
0
votes
0answers
45 views

I want to restrict the input of special characters in url with rewrite module

This is the code in the Apache conf file. RewriteCond %{REQUEST_URI} (\.\.|%2e%2e|%252e%252e|%u002e%u002e) [OR] RewriteCond %{QUERY_STRING} (\.\.|^%2e%2e|^%252e%252e|^%u002e%u002e) RewriteRule ^(.*)$ /...
1
vote
1answer
148 views

HSTS and Wordpress redirection to www and non-www and https - avoid multiple redirections?

I am trying to implement the HSTS (HTTP Strict Transport Security) on my Wordpress site, but I am not getting any success. First I had managed to redirect my site from non-www to www , and including ...
0
votes
0answers
25 views

Unable to redirect https://www.example.com to https://example.com on Apache 2.4.10

I've tried numerous methods to get https://www.example.com (the url with www) to redirect to https://example.com (the url without www) but I keep getting a certificate warning. I have http:// ...
2
votes
2answers
37 views

Execute RewriteRule proxy redirection directive after all others

I have a backend application behind a reverse proxy protected by an SSO. The SSO exports an HTTP header after successful authentication containing the userid. I need to pass this uid and other data to ...
1
vote
1answer
58 views

Apache: Inherit rewrite rules and defined variables

I have lots of typical vhosts sections that differ in one or two parameters in mod_rewrite rules, for example: httpd-vhosts.conf <VirtualHost *> RewriteRule someurl/(.*)\.html /var/www/...
1
vote
1answer
129 views

Wordpress “There has been a critical error on your website”

I am getting the following error on the login page on our Wordpress site: There has been a critical error on your website. Please check your site admin email inbox for instructions. After searching ...
0
votes
0answers
54 views

Apache 2.4 forced Forbidden when client certificate fails

Our case we are migrating sites from Apache 2.2 to 2.4, and follow a lot tips of this documentation: https://httpd.apache.org/docs/2.4/upgrading.html But still not working fine redirecting the users ...
1
vote
1answer
37 views

Apache VHost redirect aliases to HTTPS

I'm trying to do Virtualhosts on my "playground" VPS. I need it to redirect 3 or more domains to the main one. Also it should redirect HTTPS, Lets Encrypt is configured and working well. In ...
1
vote
1answer
38 views

Apache: Dynamic Reverse Proxy

is it possible to have an Apache server dynamically proxy all requests defined by a subdir? Like: https://proxy.example.com/host1 -> https://host1.example.com https://proxy.example.com/...
0
votes
0answers
48 views

How to remove part of an URL with .htaccess?

I am trying to get Prestashop to work on my Linux server. In the backend, the links return "Access denied", when they have "index.php". i.e. this does not work: shop/mi6wd5/index....
2
votes
1answer
250 views

Rewrite rule with QUERY_STRING don't work

On Apache server, i need to rewrite mydomain.com/something/?p=value to mydomain.com/something/?page=value I tried: RewriteEngine On RewriteCond %{QUERY_STRING} p=(.*) RewriteRule ^(.*)/p=$ $1?page=%{...
0
votes
0answers
64 views

removing index.php from URL

I am running a wordpress site with Astra theme. I use the custom permalinks and I would like to remove index.php from url. I have the following .htaccess file: # BEGIN WordPress ...
2
votes
2answers
78 views

mod_security 403 forbidden response is returning homepage content with WordPress mod_rewrite

I'm using mod_security on various websites, some WordPress and some not. I notice that on a non WordPress website the following: https://test-site.com/?exec=/bin/bash returns a 403 forbidden error ...
1
vote
1answer
108 views

How does Apache mod_rewrite work to restrict by IP

I would like to accept only certain IP(s) for a few weeks. Only accepted IP could load this -> www.example.com/login not the others. Apache 2.2 is used. The code in mod_rewrite as below : ...
3
votes
1answer
50 views

Why is my Apache RewriteRule removing hex codes from the target url query string?

I have an apache rewrite rule: RewriteRule ^/xy[/]{0,1}$ https://www.example.com/path/file.php?utm_source=Billboard&utm_medium=Print&utm_campaign=MyOrg%20Promo&utm_term=2020FA&...
4
votes
2answers
458 views

Syntax for apache RewriteRule to match %-encoded URLs? (to fix character encoding issues; windows-1252 <=> utf-8 )

I host a webpage that has 'project²' in the URL, matching an on-disk directory project² from where static files are hosted. This page is used by a java-based client to load data from URLs (...
2
votes
1answer
96 views

RewriteMap inside RewriteCond doesn't work (Apache)

I have a RewriteCond that checks if {QUERY_STRING} contains the right version number, if it doesn't then redirect users to the correct version. For instance if v0.7 is the latest, users accessing http:...
12
votes
4answers
3k views

How can I redirect an entire site to a single page?

I'm in the process of shutting down a site, and have replaced the old site with a single "nobody home" page at the root level of the site. Now I need to set up some redirection, so that any ...
1
vote
0answers
65 views

Apache mod_rewrite P flag is rewriting URL unexpectedly

I've recently received a request from the site owner to redirect our base domain to a specific landing page on a subdomain, which is working just fine. The problem is that he wants the URL to remain ...
1
vote
0answers
66 views

Apache2: RADIUS authentication before rewrite engine HTTPS

I tried to set up a reverse proxy with HTTPS and Radius authentication. Unfortunately, I don't get an authentication query before it redirects to the HTTPS page. What did I do wrong? <VirtualHost *:...
1
vote
1answer
251 views

Adding Wordpress .htaccess code to Apache config (for all sites) [closed]

The default .htaccess code for WordPress is: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...
2
votes
1answer
110 views

Dynamic DocumentRoot Based on SSL (Client Auth.)

I currently use Client SSL authentication to protect sensitive content. Users are required to import a certificate into their browsers that we generated using OpenSSL. When a user visits the website, ...
1
vote
1answer
288 views

.htaccess issue php $_SERVER['PATH_INFO'] is empty [closed]

On local host I was running my php (MVC) application with following rules in my .htaccess file: Options -Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-...
1
vote
0answers
419 views

How can I disable HTTP Basic Auth on my Apache instance for a specific REQUEST_URI

I have a linux instance hosting a WordPress site and it has Basic HTTP Auth enabled for the entire site. I now want to disable the Basic HTTP Auth for a specific path we can call /auth-free-url-2019. ...
0
votes
1answer
54 views

Configuring www.domain.com and domain.com with zonefile or letsencrypt to always forward to domain.com

I have a example that should always result in https://example.com, even when the user is entering www.example.com, https or not. Ideally, the automated letsencrypt config https config file should work....

1
2 3 4 5
43