Why do I get a double trailing slash depending on where my RewriteRule is located?
I am using the following code to direct all www requests to non-www URLs: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.org$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] This works great inside an .htaccess file in the root of my website. For example, www.example.com -> example.com/ www.example.com/ -> example.com/ www.example.com/other_page -> example.com/other_page However, if I move this same code into my VirtualHost configuration, the rewritten URLs contain a double trailing slash. www.example.com -> example.com// www.example.com/ -> example.com// www.example.com/other_page -> [...]
Continue Reading »IIS rewrite rules skipped even though the pattern matches
Sorry for the vague title, the problem is too complex to summarize in a short phrase… I’m trying to set up the following redirection rules: blog.mydomain.net/en/something: redirected to www.mydomain.com/something blog.mydomain.net/fr/something: redirected to www.mydomain.fr/something blog.mydomain.net/*: redirected to www.mydomain.com Rule 3 is working, but rules 1 and 2 seem to be skipped so rule 3 is always applied. Here are my web.config rules: <!– Canonicalize mydomain.com to www.mydomain.com –> <rule name=”CanonicalHostNameRule_en” stopProcessing=”true”> <match url=”(.*)” /> <conditions logicalGrouping=”MatchAll” [...]
Continue Reading »rewrite condition to target Via: Varnish 1.1
I have a Drupal site that uses Varnish. I am trying to redirect people that come to a url starting with /node when they view the site via Varnish. I have tried the following in the .htaccess file but it gives 500 errors. RewriteCond %{HTTP:Via} =1.1 varnish RewriteRule ^node / [R=301,NC,L] I haven’t been able to find anything using google in relation to how to target the ‘Via’ section of a header. Cheers, Paul Asked [...]
Continue Reading »Apache url rewrite plus sign not working as expected
I’d like to rewrite my site url of below two patterns (note: there are a lot such urls that i hope to use one rule to rewrite them all) www.hetaoblog.com/hello www.hetaoblog.com/hello/ to **www.hetaoblog.com/myblogs/post/hello.jhtml** all other cases like http://www.hetaoblog.com/ should not be changed; I’ve tried <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule . /index.php [L] RewriteRule ^([^/]+)/$ /myblogs/post/$1.jhtml [L] RewriteRule ^(.*)$ /myblogs/post/$1.jhtml [L] </IfModule> and <IfModule mod_rewrite.c> RewriteEngine On RewriteBase [...]
Continue Reading »nginx rewrite a bunch of subdomains to domain
I have configured my first nginx server, and I have to redirect subdomain1.domain.com, subdomain2.domain.com and a few more to domain.com I searched a lot about rewriting in nginx but couldn’t find anything that works. Thanks! Asked by Alex Nginx only knows about the (sub)domains that match a server_name in a server block. Requests for any other (sub)domain will end up in the ‘default’ server block, if you have one setup. You, therefore need to create [...]
Continue Reading »Nginx rewrite question
My goal is that requests for /foobar?key=123 should redirect to /download/foobar.html?key=123. I currently use the following code to accomplish this: location /foobar { rewrite ^/foobar(.*)$ /download/foobar.html$1 permanent; } This does the trick, but we have some old code that also calls /FooBar?key=123 and /Foobar?key=123 which ignores the rewrite rule. How can I get these to rewrite too? Could use: location ~* ^/foobar { rewrite ^ /download/foobar.html$1 permanent; } but isn’t this a bit loose of [...]
Continue Reading »How can I enforce that my urls always start with www?
I want to ensure that users come to www.mydomain.com even if they arrive through the alias mydomain.com. This is so that I have control over cookies on subdomains, and so that Google sees one single domain and not a hodge-podge of URLs. How can I do this with apache? <VirtualHost ip:80> ServerName domain.com RedirectMatch permanent ^(.*)$ http://www.domain.com$1 </VirtualHost><VirtualHost ip:80> ServerName www.domain.com … usual config </VirtualHost> Check more discussion of this question. Bookmark on Delicious Digg [...]
Continue Reading »Apache: Where to examine the redirection logs?
I have complicated RewriteCond and RewriteRule in one machine. And according to these rules some of the request will be redirected to another machine. So is there an Apache log that shows clearly how the redirection takes place? Because the redirection is happening in the ways that I don’t anticipated. For the uninitiated, this is how you should write your *.conf file: NameVirtualHost *:80 <VirtualHost *:80 > ServerName gw.myserver.net DocumentRoot “C:Program FilesMyCompanymyserverWeb” DirectoryIndex index.html index.php [...]
Continue Reading »Enable nice urls / permalinks in CentOS + Apache
We’ve got a fresh CentOS box and we need to enable nice urls / permalinks. We’re running Apache with mod_rewrite installed but I’m aware I need edit a few config files to get the basics up and running. What are the steps and files that need to be changed in order to get it up and running? I agree with David Pashley – this is a somewhat vague question. However I’m going to take a [...]
Continue Reading »Setting Apache environment variable on mod_rewrite rewrite condition
My rewrite rule is working and redirecting requests like /versioned/1234/images/foo.gif to /images/foo.gif but it doesn’t seem to be setting the set_expires_header environment variable because the headers are not being appended. If I uncomment the line that explicitly sets the environment variable then the headers are set. What am I doing wrong? Is there a better way to do this? I want to be able to access the files with both URLs but only have the [...]
Continue Reading »Recent Posts
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?
- Can Windows RDC admin users be immune from being kicked?
- Domain Administrators account policy (After PCI audit)



