mod-rewrite

Rewrite rule meaning

Possible Duplicate: mod_rewrite: what does this RewriteRule do? Hi, Sorry to bother you. What's the meaning of this rule ? RewriteRule ^.*$ - [NC,L] Thanks in advance. Bye ...

htaccess rewrite question

Hi, I want to rewrite the url http://mydomain/myapp/fakefolder to http://mydomain/myapp/index.php I tried the following rule but thats not working RewriteEngine On RewriteRule ^fakefolder$ index.php The .htaccess file is located inside myapp. Kindly help Thanks vineet ...

Making a 301 rewrite from within a folder using relative rewrite URLs

I have the following problem. We used many different URLs to the same page. Now we want to use only one URL for those pages. Here an example: RewriteRule ^(subfolder1/folder1/|(subfolder2|subfolder3)/folder2/|folder3/)?(name1|name2|name3|name4)$ scriptname.php [QSA,NC] As you can see it is pretty messy. What I now want to do is the fo...

A regex to match anything that doesn't start with a certain string.

I'm writing a mod_rewrite rule and would like a hand making it do what I want. Basically I want the following cases to work: request | Redirect to --------------------- cheese | /?page=cheese abc123 | /?page=abc123 abc/def | /?page=abc/def a/b/c/d | /?page=a/b/c/d (Any alphanumeric plus . - / and _ redirected) With two special cas...

How to force apache only to serve a single file?

My site uses nginx. I use apache only for large file uploading to the server. I have a script upload.php which I POST the files to via a flash uploader script. Apache runs on a subdomain, so I post files to upload.domain.com/upload.php Is there any way to prevent apache from serving the actual site on that subdomain? ideally I want to...

Can one use named backreference's in Apache mod_rewrite

All, I've come across an interesting little quirk in one of my RewriteRules, which I wanted to resolve by the use of named back references. However from what I can see, this is not possible in Apache's mod_rewrite. I have two incoming urls, each containing a key variable, which need to be rewritten to the same underlying framework acti...

Rewriting an Apache RewriteRule?

In my application's .htaccess file I have the following: Options -Indexes RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+) index.php A very lightweight file that puts all unmatched requests through index.php. However, this application is a social networking website that I've ...

RewriteCond thinks existing file does not exist

I want to achieve my /assets/img urls are rewritten to a specific location when that file exists, but otherwise to a php script. Therefore I have these rules: RewriteCond %{DOCUMENT_ROOT}assets/img$1/.$2.$4/$3.$4 -f RewriteRule ^assets/img(.*)/([a-zA-Z0-9-_\.]*)\.([^/]+)\.([a-z]{2,4})$ assets/img$1/.$2.$4/$3.$4 [NC,QSA] RewriteRule ^ass...

Rewriting problem with .htaccess (removing /index.php from CodeIgniter URLs)

I have a small issue with some .htaccess rules on our website - http://www.presencemultimedia.co.uk We've recently re-built the website using CodeIgniter. To use nice URLs I've added some lines to our .htaccess file as below : RewriteEngine on # CodeIgniter rules (forwards requests to index.php) RewriteCond $1 !^(index\.php|images|rob...

JQuery UI Click call works on local machine but not when published to server - also using CakePHP

I have some javascript that looks like this: $('.resultitem').click(function(event){ alert('check this gets called'); location.href='viewinfo/'+$(this).attr('rel'); }); this code works fine on my local machine but after uploading to the server it doesn't seem to get called at all. Can anybody help me un...

.htaccess mod_rewrite Convert file to php and don't show filetype

Given a set of URL as follows: http://site.com/filename.html http://site.com/filename.htm http://site.com/filename.php http://site.com/filename Using the mod_rewrite module in .htaccess, how can I make it request the file at http://site.com/filename.php and show the URL http://site.com/filename ...

Caching and php: Serving generated file static to speed up requests

In code, my question is: if(file_exists( c/ $requesturl ) serve( c/ $requesturl ) else serve( index.php?blah ) In human form: My script generates CSS. This is pretty intensive, so I built in caching. People request: http://domain.com/css/1lfi4wg.css2 Which is rewritten: RewriteRule ^([a-zA-Z0-9\-]*)\.css$ index.php?cssfilename...

rewriterule in htaccess to match certain file extensions

How can I look for an instance for certain file extensions, like .(jpg|png|css|js|php), and if there is NOT a match send it to index.php?route=$1. I would like to be able to allow period's for custom usernames. So, rewrite http://example.com/my.name to index.php?route=my.name Current setup: .htaccess: <IfModule mod_rewrite.c> Rewrit...

Strange problem with .htaccess

I'm having a really strange issue with .htaccess - I'm trying to rewrite the domain so it always prepends www to the domain when loaded - this works for about five minutes and then just turns the page blank!? .htaccess: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www.thedomain.co.uk$ [NC] cRewriteRule ^(.*)$ http://www.t...

Partial URL redirect with .htaccess

Hi, I'm need to redirect a a bunch of URL's through mod_rewrite. The URL structure is as follows: www.mysite.com/somescript.php?&lang=asp&variable1&variable2 Needs to redirect to www.mysite.com/somescript.php?&lang=php&variable1&variable2 So, basically, any URL with &lang=asp in it needs to be redirected to exactly the same URL bu...

mod_rewrite: how to strip url of query string yet retain it's values

I'd like to strip a URL of it's query string using mod_rewrite but retain the values of the querystring, for example, id like to change: http://new.app/index.php?lorem=1&amp;ipsum=2 to a nice clean: http://new.app/ but retain the values of lorem and ipsum, so inside index.php: $_GET["lorem"] would still return 1 etc. This is m...

mod_rewrite with multiple embedded matches

I have the following rewrite rule in my .htaccess file: RewriteRule ^([^/]+)/([^/]+)/(tab:([^/]+)/?)?(scope:([^/]+)/?)?(sort:([^/]+)/?)?(p:\d+)/?)?$ web/results.php?view=$1&q=$2&tab=$4&searchscope=$6&sortBy=$8&page=$10 [NC,QSA,L] It seems to work great when testing on some of the online regex testers that I have found. However on this ...

How to enable mod_rewrtie on ubuntu on bitnami machine on Amazon?

Hi Guys, I have created a lamp bitnami server on Amazon. I was wondering how to enable mod_rewrite on it? This is the server that I have http://bitnami.org/stack/lampstack I have tried installing "sudo apt-get install apache2.2-common" then running "sudo a2enmod rewrite" and then editing "/etc/apache2/sites-available/default" and ma...

OpenID for rails app behind Apache

Hi, I'm trying to integrate simple OpenID authentication through Google accounts. I'm using omniauth gem and on my local development system (Win7, ruby 1.8.7-p302, rails 2.3.8, omniauth 0.1.5) everything works nice. The problem shows it's face when I deploy it to my hosting (HostGator). The app (mongrel) starts at port 12002 and through...

.htaccess : if is an path, do nothing, else, do the rewriterule

Hello, I have a little question very simple this time I think... How Have I to write my htaccess to do this instructions : IF IS "/uploads" PATH INTO MY REQUEST, NOT REDIRECT AT ALL, JUST DO THE REGULAR REQUEST ELSE DO THE REWRITERULE : RewriteRule (.*) http://theDestinationDomain.com/$1 [P,L] I Have tested that : RewriteEngine on Rew...