rewritecond

How do I express this with a RewriteCond?

I want to redirect users to an error page if they enter any URL not starting with 'en' or 'fr'. I cannot figure out how to express this as a RewriteCond / RewriteRule. To be clearer, some examples: http://mysite.com/en/foo/ ==> Cool, do nothing http://mysite.com/fr/foo/ ==> Cool, do nothing http://mysite.com/foo/ ==> ERROR, redirect t...

Going mad with infinite loop and RewriteCond, need help.

I want to redirect users to my home page if they enter any URL not starting with 'en' or 'fr'. I've spent hours trying to make this work but this proves too tough for my fragile newbie brain. Currently, if I try to go to http://mysite.com/fr/produits/ Firefox tells me that the redirect will never complete. Here's what I want: http:/...

Htaccess help, $1 being used before its set??? what?

I have this snippet RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|img|css|js|robots\.txt) RewriteRule (.*) index.php?/$1 [L] It won't allow me to access a file at website.com/js/main.php but it will let me access index.php According to my webhost, $1 is...

How do I rewrite a URL based on a dynamic first directory name?

My goal is to redirect: http://users.domain.com/<username>/other/path/info to http://users.domain.com/other/path/info The key here is that that the "username" in the source URL could of course be anything. Here is a more concrete example of what I want to do (and why): Suppose I have username of "bill". I want Bill to be ab...

How would I redirect two domains using .htaccess

I'm trying to redirect one domain to the root and another to a directory. The problem I'm having is the second domain is overwriting the firsts redirection. Here is what I have. RewriteEngine On RewriteCond %{HTTP_HOST} !^http://example.site.net$ [NC] RewriteCond %{REQUEST_URI} !^/.*$ RewriteRule ^(.*)$ / [L] RewriteEngine On Rewri...

how do I redirect from a subdirectory to another directory, but strip off the original subdirectory from the URI using mod_rewrite

I have a Ruby on Rails app running on 12001. I am currently redirecting a subdomain to 127.0.0.1:12001 using some ReWriteCond detection. Now I want to redirect my subdirectory to that rails app. http[s]://domain.com/redmine to 127.0.0.1:12001 The current rules apply REQUEST_URI to the above rails path, but I need to strip "/redmine...

mod_rewrite and pretty urls

What I'm trying to achieve: 1) http://localhost/en/script.php?param1=random is mapped to http://localhost/script.php?param1=random&language=English This has to work always. 2) http://localhost/en/random/text/here will be mapped to http://localhost/categories.php?term=random/text/here This has to work if random/text/here is 40...

Apache rewrite URL replace characters

It's been a while since I've done anything with mod_rewrite, so I was hoping I could help some help on this. I would like a URL like this: http://example.com/qwerty/xyz/ to be directed to querty.xyz.php, where the number of slashes and alpha characters between the slashes is not explicitly set. ...

RewriteCond and RewriteRule newbie

I'm taking over a website for a client that is running on a custom built CMS (that I didn't write). I don't mess with .htaccess files usually because a lot of the hosting I do is on IIS, or I used WordPress as a CMS and don't have to worry about messing with the .htaccess file. Here's the contents of the file: RewriteEngine on Rewrite...

Checking if file exist with RewriteCond in a chained RewriteRule

Hello, I hope you could help me here. I have a RewriteRule which gives you a crossdomain.xml file depending on the domain name. I have it in a way that ignores the ".dev." string in the middle, example: Request: http://site1.dev.mydomain.com/crossdomain.xml Returns file: /etc/httpd/conf/crossdomain/site.mydomain.com.xml RewriteCond %...

Apache mod_rewrite RewriteCond to by-pass static resources not working

I can't for the life of me fathom out why this RewriteCond is causing every request to be sent to my FastCGI application when it should in fact be letting Apache serve up the static resources. I've added a hello.txt file to my DocumentRoot to demonstrate. The text file: ls /Sites/CioccolataTest.webapp/Contents/Resources/static hello...

How do I redirect this right with .htaccess

Yeah, Iam trying to make the _PRIVATE folder out from the web itself I cant figure out how I do a /../ redirect. Because this is happening in Apache it should allow it somehow. I want ../ because sometimes _PUBLIC is www root, depends on the large sets of webhosts out there, and I want it to work on both setups =/ Structure / (www ro...

change cat-art.php into cat/art.php

Hi i got a problem with changing urls. I have files: cat-art.php (cat- category, art- title of an article) and i would like to have nicer access to them: cat/art.php so i wrote some code in .htaccess but it doesnt work. RewriteCond %{REQUEST_URI} ^/([^-]+)/([^-]+).html$ RewriteRule ^([^-]+)/([^-]+).html$ $1-$2.html [L] Can sb help me...

RewriteCond simply doesn't work, doesn't check properly if file exists

Hey everybody. I've been trying to solve this for hours now but came up with nothing. Inside .htaccess, whenever somebody requests an image from a folder of my website, I'm trying to check if a file with the same name exists in another folder; if it does, return that file; if it doesn't, return the file originally requested. It seems ...

Using altered RewriteCond to check if file exists in multiple locations

I want to use mod-rewrite to check for a file in two separate locations: at the requested URL, and at the requested URL within the "public" directory. Here's what I have so far: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/public/$0 !-f #this line isn't working RewriteRule ^(.*)...

redirecting directories with a few exceptions using .htaccess and mod_rewrite

I'm using mod_rewrite in a ManagedFusion settings file (similar to .htaccess) and I want to forward all incoming requests to another port on the server, except for a few folders. So far I have this (with the folder ui, forms, clientsystem and widgets being ignored) RewriteEngine On RewriteCond %{REQUEST_URI} !ui$ RewriteCond %{REQUE...

Redirect additional domains to the single in use-domain using Apache mod_rewrite in .htaccess

RewriteEngine On RewriteCond %{HTTP_HOST} ^someparkeddomain.com RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^www.someparkeddomain.com RewriteRule ^(.*)$ hxtp://www.thedomainUsed.co.uk/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^anotherparkeddomain.co.uk RewriteRule ^(.*)$ hxtp://www.thedomainU...

RewriteCond to change displayed host, but not server

Typing out the title to this leads me to believe this might not be possible due to security concerns, but I will ask anyway. I have shortcode support running on my server, lets call it xx.yy I want it so when a user sends a request to xx.yy, it just changes the displayed host to another valid domain running on the same box. I have thi...

How do I interpolate values in the TestString portion of an .htaccess RewriteCond?

How do I interpolate values like %{REQUEST_FILENAME} in the TestString part of a RewriteCond directive? Here's what I'm trying to do: # non-existent requests to /webroot files get 404'd RewriteCond site/%{REQUEST_FILENAME} !-f RewriteRule ^/?webroot site/webroot/404 [L] # otherwise, let them in! RewriteRule ^/?webroot/(.*)$ site/webroot...

How do I redirect a not found FLV file to a 404 FLV file, using .htaccess?

Using .htaccess, how do I permanently redirect all not found *.flv files in one directory to a 404.flv file in the same directory. For example: If this file is not found: example.com/flv/*.flv Use this file: example.com/flv/404.flv Here's what I have so far (I'm very bad): RewriteCond /flv/(.*).flv !-f RewriteRule ^ /flv/404.flv [L,R...