I'm stuck in rewriting a url. The context is :
my website is physically stored under a subfolder www/blog-voyage/ : (which means"travel blog" in french).
I have a rule redirecting www.example.com to www.example.com/blog-voyage/
I have a multilingual website, meaning :
french post : www.example.com/blog-voyage/my-article-name
english post : www.example.com/blog-voyage/en/my-article-name
As you can see, I still have /blog-voyage/ in the english url.
Do you have any idea how I could "translate" /blog-voyage/ to /travel-blog/ only for the english url please, keeping in mind /blog-voyage/ is a real folder while the translation /travel-blog/ is just a translation of the words and there is no folder /travel-blog/.
Thanks a lot,
Jérémy
add this
RewriteRule ^blog-voyage/$ /travel-blog/ [L]
ps. I'm English speaker I know voyage means travel ;)
Am I right saying the previous answer will redirect everything and not only my english pages ?
Related
I have two versions of the same page:
example.com
example.com/fr -> French version
I would like French people who access to mydomain.com to be redirected to mydomain.com/fr based on the header Accept-language. To do that I wrote this into my .htaccess:
RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule ^$ http://example.com/fr/ [L,R=301]
I works perfect so far.
But in my site there are links to the French / English versions... When a French user who is in the French version clicks on the english link, he comes back to the french version... How can I avoid this? How can I distinguish he actually wants to go to the English version?
A Suggestion may be to include links to the top of your page - each to different pages, for example; FR - mydomain.com/fr, ENG - mydomain.com/eng
Depending on the context of the website - I would then set either the French or English versions of the website as the default.
You can add a parameter on the query string to the internal language links, to prevent the normal language redirection from happening when the user has clicked a link to a specific language.
Then add an extra RewriteCond to your .htaccess to check whether the user has clicked an internal link:
RewriteCond %{QUERY_STRING} !(nolangredirect=1)
So if a French user clicks on www.example.com/en/index.html?nolangredirect=1 they will not be redirected to the French version.
If you want them to see the English version next time they come back to the website, you'll need to use cookies.
I´ve set up a prestashop and have activated two languages Danish and English. The English version will not be used for a while, but I want search engines to cache the domain.com/webshop/da/ from the beginning. I didn´t know how to add the /da/ with .htaccess.
The problem is that even if robots.txt exclude the /en/ peoples browser language (en) will put prestashop into /en/.
I would like to redirect the domain.dk/webshop/en/[products] to domain.dk/webshop/da/[products]
So customers do not land on the English version that is not translated.
How can I do that?
Or do you see a better solution for me?
Have a nice day. Best T
I would like to redirect the domain.dk/webshop/en/[products] to domain.dk/webshop/da/[products]
You can use this rule as your very first rule in /webshop/.htaccess:
RewriteEngine On
RewriteRule ^en/(.*)$ /da/$1 [L,NC,NE,R=301]
I'm building a new site using Joomla and I've selected 'Search Engine Friendly URLs' and 'Use URL rewriting' in the Global Configuration which gives good SEF URLs but not quite perfect!
If a link to a page doesn't have a menu item associated to it the URL would look like this:
example.com/10-category/5-article
I want to remove the numbers and the hyphen using htaccess so it looks like:
example.com/category/article
I've made Rewrite Rule's in my htaccess file that looks like this:
RewriteRule ^([0-9]+)-(.*)/([0-9]+)-(.*)$ /$1$2/$3$4 [R=301,L]
RewriteRule ^([0-9]+)(.*)/([0-9]+)(.*)$ /$2/$4 [R=301,L]
The browsers address bar now shows the URL I want, example.com/category/article but the page shows a 404 error!
Is it something to do with the Joomla SEF?
What am I doing wrong?
*Update*
The first RewriteRule which removes the hyphen only works OK by itself, I only receive the 404 error page when both RewriteRule's are active.
This is a blind guess, Joomla probably needs those numbers to know which content to serve. It cannot just tell by the name of the category or article (in fact in most of these cases you can even leave it out), but it's the number that's important.
So when you're rewriting the URL without the numbers, you're requesting pages that Joomla has no idea how to handle, and it'll give you a 404. The only solution would be to write a plugin or something that maps the names of categories and articles to the corresponding IDs, but that's not going to be easy.
Concerning SEO, I don't think the number in the url is that much of a negative effect. If the rest of your website's SEO is good then this won't matter.
i change the permalink of wordpress with the rule "/%postname%/" and it's working perfectly.
The only problem i use wp-commerce and for some reason generate the permalink to the product with this in the end "&negozio=NEGOZIO" and so give for every product i want to see a 404 page.
I know with .htaccess you can rewrite urls so i'm asking what's the correct rule for make a link like this :
http://www.ctssolutions.it/products-page/gestione-banconote/bj-140/&negozio=NEGOZIO
became something like this :
http://www.ctssolutions.it/products-page/gestione-banconote/bj-140/
Thank in advance
I need to redirect incoming requests for a page to a subdirectory whilst keeping the URL displayed as originally typed.
This is to manage language pages easier.
For example, I want Spanish pages to be under www.mydomain.com/es. I want the URL displayed to remain www.mydomain.com/es.
But the actual page is held here - www.mydomain.com/international/es
This means I can keep my root folder tidy and have all the language pages in one directory. But I want it to be easy for language specific visitors to find thier page.
Can anyone point me in the right direction? I've had a go but to be honest I always manage to produce server errors and get in a mess.
Many thanks
TT
Provided you are on an apache server look up mod_rewrite.
Example for your .htaccess:
RewriteEngine on
RewriteRule ^es/([0-9a-zA-Z\/]*)$ /international/es/$1 [L]