I have looked everywhere but I couldn’t find my problem or a solution to it.
I’m pretty sure this is just linked to my only basical knowledge of .htaccess
files, so I’m sorry if this is only a basic or even stupid simple question.
What I want: a multilingual WordPress site. I know there are some plugins for that, but the problem is they are either not compatible with the latest version of WordPress (qTranslate) or paid (which we don’t want). I’m not afraid of coding it myself, I’m a theme developer so what concerns the theme code that’s not a problem.
When it comes down to the slugs however, I’m stuck. I’m considering building a sort of plugin that provides me with the possibility to “add” a slug for a certain language. When I save that slug, I’d edit the .htaccess
file to rewrite the new slug.
For example: ‘a propos de nous’ would be rewritten as ‘about-us?lang=fr’ so that I’d be able to parse the lang attribute in my template and see I’d need to pull the French content.
RewriteRule ^(a-propos-de-nous)$ about-us?lang=fr
Now, this doesn’t work. As said, I guess it’s a problem with my RewriteRule
code. I just can’t figure out how this needs to be done properly.
For the record, here’s the content of my .htaccess
;
<IfModule mod_rewrite.c>
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
# BEGIN custom slugs
RewriteRule ^(a-propos-de-nous)$ about-us?lang=fr
# END custom slugs
</IfModule>
EDIT: apparently you can add new rules inside the WordPress code. See this question: URL rewriting via WordPress Rewrite or .htaccess Edit8 solved my problem as well.
As asked, this was the solution to my problem:
apparently you can add new rules inside the WordPress code. See this question: URL rewriting via WordPress Rewrite or .htaccess [SOLVED] Edit8 solved my problem as well.