Questions tagged [mod-rewrite]

mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs.

For an introduction and examples of using mod_rewrite, read over the comprehensive article,
"Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask"

2224 questions
1
vote
1 answer

Apache mod_rewrite with Redirect Dropping Authorization Header

I have some Apache mod_rewrite rules set up to redirect Maven deploys from one url/server to another. We're in the process of migrating from Nexus to Artifactory and need these redirects set up so that teams can still use the Nexus URLs for a…
user571393
1
vote
0 answers

Configurate Apache 2.4 reverse proxy with redirection

Server1 runs apache proxy and webserver tomcat domain: example.com/app1. Server2 runs just webserver tomcat example.com/app2. I'd like to redirect example.com/ to example.com/app1 and app2 server not redirect just stay on example.com/app2. Also need…
user298785
  • 11
  • 3
1
vote
1 answer

apache mod rewrite - initial URL equal rewritten URL

I have rewrite rules and get many logs like: [Thu Mar 26 11:41:00.356526 2020] [rewrite:trace1] [pid 18095] mod_rewrite.c(483): [client xy.xy.220.72:56702] xy.xt.220.72 - - [app.xyz.com/sid#7f7996613868][rid#7f79964eb0a0/initial] [perdir…
Niro
  • 1,401
  • 4
  • 20
  • 36
1
vote
1 answer

Apache RewriteCond not catching keywords as expected for QUERY_STRING

I'm trying to setup a RewriteRule for Apache 2.4 that allows me to return a 403 code when any keywords are found in the QUERY_STRING. I'm trying to return 403 whenever anyone does some malicious attacks such as: wget /etc/passwd or wp-login in the…
Tim
  • 203
  • 1
  • 9
1
vote
1 answer

Does Apache reverse-proxy pipeline requests to origin servers?

When configuring Apache as a reverse proxy (i.e. using ProxyPass or RewriteRule [P]), does it ever pipeline the requests to origin servers, or are they always sent non-pipelined? This is important to know if an origin server doesn't handle pipelined…
1
vote
2 answers

Redirecting old, specific filters to base url of category

Old version of filters and sorting was creating links like (explenation of every part is below - here is example for same category with different views and filters…
oska
  • 33
  • 5
1
vote
1 answer

Apache - mod_rewrite - backreferences understanding

httpd Apache server -> mod_rewrite -> backreferences The following picture is about understanding the reference to parentheses ([Flags] are omitted). If you use parentheses, backlinks are made to what is in parentheses and then you can use it…
Ogi22
  • 11
  • 2
1
vote
1 answer

Mod rewrite to get ID from URL

I have the following real URL structure /folder/folder2/file1.php /folder/folder3/file2.php where file1 and file2 could be any PHP file. I also have /folder/folder2/folder4/file1.php /folder/folder3/folder4/file2.php What I want to is change the…
Lawrence Cooke
  • 167
  • 1
  • 1
  • 7
1
vote
1 answer

How to redirect from document root to a folder with apache2 mod_rewrite

I have Apache2 on Ubuntu serving several hosts. Some of the hosts have Website and API parts and some folders like uploads which should be kept outside of the document root. I would like to organize them in the following file structure: domain …
yaugenka
  • 115
  • 5
1
vote
1 answer

Apache2 wildcard alias

I have the following wildcard vHost: ServerAdmin hostmaster@example.de ServerName autodiscover.*.* ServerAlias autoconfig.*.* RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*)…
1
vote
2 answers

Apache rewrite any subdomain except one to non-www https

I'm trying to reduce the amount of 301 redirect chaining on my server so I'd like to combine a subdomain to non-www redirect (except where the subdomain is dev) with a HTTP to HTTPS redirect (using %{HTTP:X-Forwarded-Proto}) as the instance is…
Matt Parkins
  • 145
  • 5
1
vote
1 answer

Setting up two sites on the same IP machine

I have CentOS 8 I installed LAMP, Varnish, etc. I setup hosts /etc/hosts ip site1.com www.site1.com ip site2.com www.site2.com I setup Apache like this: /etc/httpd.conf to include sites-enabled/ I have sites-enabled and sites-available with two…
Wed
  • 15
  • 9
1
vote
1 answer

Removing trailing slash from redirected URLs (.jpg/ .htm/ .gif/) with Apache

I have a website that is being redirected from an old host. I don't have the ability to change the redirect of the old host. The issue is that the redirect is appending a trailing slash when it's not appropriate. Example:…
Josh
  • 13
  • 2
1
vote
1 answer

.htaccess Rules to Rewrite Directory as Query Variable

Our site uses the following schema: example.com/channels/channel_name?v=videoId I would like to be able to capture the channel_name directory and rewrite it as a query variable like so: example.com/channels?watch=channel_name&v=videoId What…
0
votes
2 answers

forum.mydomain.org to mydomain.org/forum/

Would I be possible to rewrite forum.mydomain.org to mydomain.org/forum/ with mod_rewrite? Because I cant get subdomains working -- Update -- Sorry Chris, your answer didn't work. My domain has an subdomain called forum with an a-record with my…
Hogen