开发者

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 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜