URL rewriting module for Apache web servers

learn more… | top users | synonyms (1)

199
votes
5answers
59k views

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 ...
45
votes
4answers
151k views

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: <VirtualHost *&...
15
votes
2answers
17k views

best way to debug nginx 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 ...
8
votes
6answers
14k views

apache server-status not found. check if mod_status is enabled

I've enabled the apache_ plugins on a munin node: ln -sv /usr/share/munin/plugins/apache_* /etc/munin/plugins/ After restarting the node with service munin-node restart here are the errors I'm ...
5
votes
2answers
4k views

Understanding apache 2.4 mod_proxy_fcgi and RewriteRules in htaccess

We've recently switched one of our web servers to apache 2.4 and running PHP via php-fpm and mod_proxy_fcgi. Most everything works quite well, but there is one problem that I don't understand yet. One ...
1
vote
2answers
1k views

Mod ReWrite Catch-All Subdomain

Basically I want *.domain.com to pull up domain.com/*/ (not redirect). I went into the subdomains section of cPanel and set a wildcard for this domain. It appears to be resolving correctly, ie *....
0
votes
5answers
6k views

Configuring Apache, Tomcat, mod_jk and mod_rewrite to serve up tomcat from top-level

I'm trying to set up my java app as the main component of a new site. I have some static resources I'd like served by Apache, so I setup Apache and Mod_jk, with the following rules, JkMount /...
9
votes
4answers
6k views

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, ...
4
votes
1answer
3k views

Forcing SSL in Apache without hard-coding the hostname

I think that I have this sorted (thanks mainly to the question How to redirect non-www to www without hardcoding using .htaccess?), but I still don't entirely understand a couple of things. I would ...
3
votes
2answers
266 views

Is there an Elegant solution to rewrite long image?query-urls into cachable_nice_urls, using only apache htaccess?

this is a pain in the ass-problem! Whicever genius solves this riddle will receive paypal donation to eat diner for two. Now lets get started. Given: most proxies, do not cache resources with a "?" in ...
2
votes
3answers
9k views

How do I make RewriteCond %{HTTP_COOKIE} match a cookie value exactly? [duplicate]

How do I make my rule match an exact value of a cookie? I've tried: RewriteCond %{HTTP_COOKIE} ^its=me$ [NC] RewriteCond %{HTTP_COOKIE} its=^me$ [NC] RewriteCond %{HTTP_COOKIE} its="me" [NC] ...
1
vote
1answer
207 views

Why servers error log states lots of file doesn't exist, but files are accessible and website works well

we migrated our website onto VPS server (CentOS 5.6 + Plesk 9.5), everything works nice, but one strange thing that i noticed in Plesk, is error_log file, most of the time it filled up with hundreds ...
1
vote
1answer
624 views

Apache Dynamic Virtual Host with SSL [duplicate]

I have the following in my httpd.conf file NameVirtualHost *:80 <IfModule mod_vhost_alias.c> <VirtualHost *:80> ServerAlias * UseCanonicalName Off LogFormat "%V %h %l %u %t ...
5
votes
2answers
11k views

How can I redirect any ServerAlias to the respective ServerName?

I want to 301 redirect all example.org to www.example.org. The following example is doing just that, but it's got a lot of noise to it and is thus hard to maintain and error prone: <VirtualHost ...
2
votes
4answers
2k views

Apache rewrite rules and DNS settings for HTTPS sites

For a web application located at: https://www.domain.com/ With an SSL certificate issued to "www.domain.com", What is are the proper rewrite rules, DNS settings, or combination of both which makes ...
1
vote
1answer
582 views

Make post title as a slug in url by mod rewrite

I have previously posted a question but I am not satisfied with the answers. I have a url, for example http://example.com/details.php?a=100&b=101&slug=power-programming-in-php I want to ...
6
votes
1answer
16k views

SSL setup with apache in front of tomcat

i m trying to setup Apache with SSl and proxy SSL requests to my tomcat instance. I think i made the SSL work but theres still a error that shows up: Bad Gateway The proxy server received an ...
8
votes
1answer
5k views

max length of url 257 characters for mod_rewrite?

My url scheme is /foo/var1-var2-var3.../bar I am using these mod_rewrite rules: RewriteBase /foo/ RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
7
votes
4answers
9k views

Why do .htaccess redirects work in http but not with https?

I have a simple .htaccess file that works great on the http version of the site but not when I go to https. Why? RewriteEngine on #This is so if the file exists then use the file RewriteCond %{...
4
votes
4answers
2k views

Preventing vulnerability scripts from scanning apache server

Quick question for you all - fairly frequently in my httpd logs I see things like this: 66.11.122.194 - - [29/Jan/2010:11:06:44 +0000] "GET HTTP/1.1 HTTP/1.1" 400 418 "-" "Toata dragostea mea pentru ...
1
vote
3answers
17k views

Why is https not working?

I am trying to redirect just the root of my site to https. Although the rewrite happens, https does not yield anything. The browser says. connecting to thinkingmonkey.me... and stagnates. ...
0
votes
1answer
8k views

Custom Apache ErrorDocument with proxy balancer & RewriteEngine

I'm running into various problems trying to add custom ErrorDocuments to my server. I'm using proxy balancer to share the load between two instances of Zope and some simple rewrite rules to map my ...
7
votes
2answers
6k views

How to port Apache rewrite rules to cherokee?

I'm pretty new to cherokee, it's great and pretty straight forward except URL Rewrites. Is there a straight forward guide to it? Let me know. Also how would I port this: RewriteEngine on RewriteCond ...
4
votes
1answer
523 views

Dynamic subdomains, mod_python and trac

I'm going to be running multiple subdomains, eventually too many to be able to each have their own config files. I have the vhosts working how I want them so each subdomain has their own folder eg /...
4
votes
3answers
332 views

The 301 'www' nightmare. How do I change back?

About six months ago, I decided it would be best to put my website on the naked domain, let's just say 'example.com'. I did what all the instructions websites have told me with adding a 301 redirect ...
3
votes
2answers
976 views

How can I use apache to redirect users (based on user_agent and using mod_rewrite) to my mobile site only if a mobile pages exists.

I want to detect mobile users based on their user_agent. If a user is browsing the full version of the site and they have a certain user_agent, I want to redirect them (using mod_rewrite) to the ...
2
votes
1answer
3k views

Mod-proxy with query string alternatives?

I am currently trying to use mod_proxy to make search requests on another server. The remote server requests must be structured as follows: http://path.to.remote/search.php?key=MYKEY&term=...
2
votes
2answers
9k views

Apache Rewrite or Proxy to internal server

First off, this is my first go at apache, so please forgive my beginingingismness :) My basic setup is as such: mysub.domain.com gets sent to my static IP via a CNAME entry at godaddy's DNS manager. ...
2
votes
1answer
97 views

mod_rewrite with multiple QUERY STRINGS

This is an extension to my question http://serverfault.com/a/761474/77231 I am trying to add an additional QUERY STRING parameter to the URL and change spaces to underscores but am having no success. ...
1
vote
1answer
224 views

Redirecting a specific URL to a different vhost in apache

I have two versions of a very small ruby-on-rails apps running on my web server. One is served externally (production) and one is served only on an intranet URL (staging). So I have two Virtual ...
1
vote
1answer
981 views

Apache Rewrite or Redirect?

I want to redirect a http://site.com/ to http://site.com/url. What is the simplest way to do this? I tried editing httpd.conf and to the redirect command. It didn't worked. Also I tried creating a ...
1
vote
3answers
780 views

broken apache .htaccess (mod_rewrite)

Hey there, I'm running into an apache mod_rewrite configuration issue on one of our machines. Has anyone encountered / overcome anyone of these issues. URL1 ( http://www.uppereast.com ) is not ...
1
vote
2answers
123 views

redirect not-active subdomains

EDIT: How can you redirect all non-active subdomains to 'www'? Here I try to redirect all subdomains not listed to 'www'.. I can't make it work properly because %1 and %2 doesn't return anything.. ...
1
vote
1answer
804 views

Apache: mod-rewrite to look up missing images in another directory

I am new to Apache mod rewrite. What I would like to achieve is this. If an image (gif, jpg, png) is requested from an url and is not found there, it should automatically try to deliver this image ...
0
votes
3answers
160 views

How can I test for a URLs existeance before redirecting to it?

I am using Apache's mod_rewrite to redirect mobile users to my mobile site based on their http_user_agent. However not all pages have a mobile equivalent. Also mobile pages end in .html and "full" ...
0
votes
1answer
202 views

url rewrite to make generated thumnails cache like static, a syntax question

this is a pain in the ass-problem!! Given: most proxies, do not cache resources with a "?" in their URL even if a Cache-control: public header is present in the response. To enable proxy caching for ...
0
votes
1answer
57 views

mod_rewrite to replace all dots with underscores after path

I've been through all tagged questions here and on SO, but my problem is different because of either/both needing to replace "." with "_" comes after a particular path and I'm running through a ...
0
votes
1answer
308 views

Compact Redirects in Apache/htaccess. How? [An Elegant Coding Question]

when setting my redirects in htaccess, i have trouble setting/combining various domains when they all go to the same homepage. I can do them separate, but that isn't neat/elegant. How to rewrite the ...
3
votes
1answer
69 views

Multiple rule Apache rewrite

I am trying to set up a hierarchy five levels deep with mod_rewrite. This is what I have put together at this point. It works for the last two levels (the first and second rule) but not after that. ...
3
votes
1answer
349 views

How would you replace this rewrite rule with a redirect?

This Apache reference page and this wiki clearly states that to achieve simple http to https redirects, mod_alias should be used instead of the more expensive mod_rewrite. I have an Apache ...
3
votes
2answers
857 views

mod-rewrite: Replacing some characters in a url

Is it possible to replace some forward slashes (/) of a URL to dots (.) in a RewriteRule? It doesn't have to be done exclusively with a RewriteRule, but definitely not with a script. Example 1: ...
2
votes
1answer
1k views

How to set the VirtualDocumentRoot based on the files within

I'm trying to set up Apache to use the VirtualDocumentRoot directive but my sites aren't all exactly the same. Most of the sites have a drupal folder which should be the root but there are a few ...
2
votes
1answer
1k views

mod_rewrite adding documentroot to url

The following rewrite redirects http://example.com/ to http://example.com/www/www.example.com/public%5Fhtml instead of http://www.example.com/. /www/www.example.com/public_html is the DocumentRoot. # ...
2
votes
1answer
259 views

Can Apache .htaccess convert the percent-encoding in encoded URIs from Win-1252 to UTF-8?

I want to add a directive in my .htaccess, such that if the browser is pointed at a URI containing %E4 (ä) - or any other special character - the .htaccess automatically rewrites %E4 (ä) as %C3%A4 (ä)....
2
votes
2answers
785 views

Order of mod_rewrite rules in .htaccess not being followed

We're trying to enforce HTTPS on certain URLs and HTTP on others. We are also rewriting URLs so all requests go through our index.php. Here is our .htaccess file. # enable mod_rewrite RewriteEngine ...
1
vote
4answers
914 views

HTTPS / HTTP mod_rewrite rules, strange interaction with subsequent CMS index.php rewrite

With the below rewrites in htaccess, as expected, this HTTPS request is not rewritten: https://example.com/system/anything is not re-written to http://example.com/system/anything But, ...
1
vote
1answer
61 views

static resources not found when mod_rewrite

I am trying to beutify the url so I have created the following .htaccess file: Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f #...
1
vote
1answer
2k views

Redirect subdomain to subdomain on new domain

I own 2 domains sio-india.org and sio-india.com What i want to do is redirect all the subdomains from 1st domain to 2nd domain. eg. home.sio-india.org to home.sio-india.com but i dont want to ...
1
vote
0answers
236 views

Apache: Setting up a reverse proxy configuration with SSL with url rewriting

There is a host: secure.foo.com that exposes a webservice using https I want to create a reverse proxy using Apache that maps a local http port on a server internal.bar.com to the https service ...
1
vote
1answer
1k views

How to rewrite URI from root if file exists in folder?

I have a public folder in my document root. I would like to redirect all the files that are not present in document root, but are present in the public folder. (So if the same file is in two places, ...