views:

23

answers:

1

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 been tasked with making multi-lingual. Therefore, URLs like www.example.com/profile/martin need to be converted in to say, Spanish, and will therefore become www.example.com/perfil/martin.

Therefore, my question is: is it possible to rewrite a RewriteRule? In this instance, I want to rewrite /perfil/martin to /profile/martin, but then have /profile/martin passed to index.php.

A: 

Adding the following line before the 'RewriteRule ^(.+) index.php' line should achieve what you want.

RewriteRule perfil/(.*) profile/$1

I'd argue that you should be doing this in your web app's URL routing code though, rather than the htaccess file.

burriko
Really? I started doing that, but thought having dictionaries of these in my application's code would start to become messy and hard to maintain. But then again, no more so than maintaining `.htaccess` rules. Thanks!
Martin Bean