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
284
votes
5 answers

Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About mod_rewrite Rules but Were Afraid to Ask

This is a Canonical Question about Apache's mod_rewrite. Changing a request URL or redirecting users to a different URL than the one they originally requested is done using mod_rewrite. This includes such things as: Changing HTTP to HTTPS (or the…
Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448
71
votes
4 answers

Redirect URL within Apache VirtualHost?

I have a dedicated server with Apache, on which I've set up some VirtualHosts. I've set up one to handle the www domain as well as the non-www domain. My VH .conf file for the www: DocumentRoot /var/www/site ServerName…
DisgruntledGoat
  • 2,629
  • 4
  • 28
  • 36
65
votes
4 answers

best way to debug nginx rewrite rules in config file?

I have a bunch of rewrite rules that I have to port from apache to nginx. It's a rather painful process because I'm not able to see if my rewrite rules and "if" conditions are working as I want them to. Apache did have debugging for its rewrite…
Jiho Kang
  • 1,047
  • 2
  • 10
  • 8
36
votes
3 answers

How to Exclude an URL for Apache Mod_proxy?

We have two Apache server as front-end and 4 tomcat server as back-end configured using mod_proxy module as load balancer. Now, we want to exclude an single tomcat url from the mod_proxy load balancer. Is there any way or rule to exclude? Proxy…
Mughil
  • 1,929
  • 1
  • 19
  • 28
20
votes
3 answers

Suspicious .htaccess File

This was uploaded to one of my FTP folders. I'm not familiar with Apache, but still curious - can someone tell me what type of dastardly act this file is trying to commit? Thanks! RewriteEngine On RewriteCond %{HTTP_REFERER} .*google.*$…
ovinophile
  • 303
  • 1
  • 4
20
votes
9 answers

How to I test if mod_rewrite is enabled?

I'm setting up an environment for WordPress on apache2, on a fresh install of Ubuntu 12.04. In order to get friendly URLs working, I'm trying to set up mod_rewrite. I followed some instructions I found on the net, and used a2enmod. Now, after…
user124130
  • 201
  • 1
  • 2
  • 3
18
votes
3 answers

Returning "200 OK" in Apache on HTTP OPTIONS requests

I'm attempting to implement cross-domain HTTP access control without touching any code. I've got my Apache(2) server returning the correct Access Control headers with this block: Header set Access-Control-Allow-Origin "*" Header…
Mark McDonald
  • 586
  • 1
  • 4
  • 12
17
votes
2 answers

Apache URL rewriting in reverse proxy

I'm deploying Apache in front of a Karaf-hosted application (Apache and Karaf are on separate servers). I want Apache to operate as a reverse proxy and also to hide part of the URL. The URL to get the log-in page of the application directly from…
16
votes
3 answers

apache2.4 mod_rewrite exclude specific alias directroy/uri

I have the following setup on one of my vhosts: ... ServerName cloud.domain.de ServerAdmin webmaster@domain.de ServerSignature Off Alias "/.well-known/acme-challenge"…
FleBeling
  • 163
  • 1
  • 1
  • 5
15
votes
4 answers

Controlling Nginx proxy target using a cookie?

I'm trying to convert a reverse proxy using an interesting Apache mod_rewrite setup to use Nginx instead (due to external concerns we are moving from Apache to Nginx, and most everything works fine except this part). My original setup was to read an…
Guss
  • 2,670
  • 5
  • 34
  • 59
14
votes
2 answers

Apache rewrite multiple conditions

I have a website that's migrated from an old domain name (e.g. olddomain.com) to a new domain name (e.g. newdomain.com). For SEO reasons, I need to rewrite all website traffic to the primary new domain name (e.g. www.newdomain.com). Unfortunately,…
gurun8
  • 345
  • 1
  • 4
  • 11
13
votes
2 answers

Why is enabling the rewrite log in .htaccess not working?

I want to enable rewrite logging so that I can debug a rewrite rule but adding the RewriteLog directives is causing a 500 error. Version information: Ubuntu 14.04 Server version: Apache/2.4.12 (Ubuntu) Server built: Feb 4 2015…
codecowboy
  • 1,307
  • 7
  • 18
  • 31
13
votes
1 answer

Apache mod_rewrite double encodes query string on redirect

We've encountered a strange issue (a bug, perhaps?) with Apache mod_rewrite's behavior when passing through query strings. To reproduce, we've set up a clean Ubuntu (oneiric) install with the default Apache configuration. We have enabled…
Erik Hesselink
  • 231
  • 2
  • 7
13
votes
4 answers

Rewritten URLs with parameter length > 255 don't work

I'm using mod_rewrite to rewrite URLs like this: http://example.com/1,2,3,4/foo/ By doing this in .htaccess: RewriteEngine On RewriteRule ^([\d,]+)/foo/$ /foo.php?id=$1 [L,QSA] It works fine, except for when "1,2,3,4" turns into a string longer…
philfreo
  • 987
  • 2
  • 9
  • 22
13
votes
3 answers

How can I enable mod_rewrite in apache on Ubuntu?

How do you enable mod_rewrite with Apache in Ubuntu 10.04? I tried copying rewrite.load from /etc/apache2/mods-available to etc/apache2/mods-enabled but that didn't work.
Nathan Osman
  • 2,725
  • 7
  • 32
  • 46
1
2 3
99 100