default language root level [closed] - .htaccess

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Hi I currently run a multilingual website organized as follow:
site.com/fr/ (france),
site.com/be/ (belgium),
site.com/uk/ (UK)
...
and site.com is a page where we can select countries/ languages.
I heard and read that it's not a good practice to do so, that I should rather set a default language for site.com
my question are:
1- should i add for example US english as default language?
2- remove the /fr/ and set a permanent redirect to the root (.com/fr/product redirected to .com/product)
3- or maybe do you have better suggestions?
Thanks you so much in advance

I do the same thing with one of my sites. But, in PHP, I change the position of the root (with or without /fr/ links). That way I can use a default language: site.com/
I choose this language automatically, with user browser language preferences. For the first page, and after link to the correct language (or to others with links). For me, it's the best SEO solution.
I just have to add rel="canonical" link elements, to avoid the duplicate or similar content:
Google: Use canonical URLs

Related

Need to check rewrite rule [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 days ago.
Improve this question
Please can you help to correct a rewrite rule on a wordpress website.
My urls are like this one :
https://mywebsite.fr/activity/city/?location_search=city+region+country+&tax-listing_category=Activity
I want this url :
https://mywebsite.fr/activity/city/
So I need to remove everything after "activity/city/"
I tried this but not working :
RewriteRule ^([-a-z_]+)/([-a-z_]+)$ /$1/$2/^ [NC,L,QSA]
EDIT :
The urls are like this because it's wordpress pages (hierarchical structures parent-page/child-page/) and I add in the urls parameters to pre-fill the search-form in the page
You can have a look here : bit.ly/3RUybZD
If you try to remove all parameters from the url, you will see the search-form and listings updated
Thx

htaccess rewrite for clean 2 get variables php [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Please I have this url
http://sub.maydomaine.com/wallpapers.php?category=cities&name=San%20francisco
I want redirect to
http://sub.maydomaine.com/wallpapers/cities/San%20francisco
Please help me .
If you add this rewrite rule, you should be able to support both urls:
RewriteRule ^wallpapers/([^/]+)/([^/]+)$ wallpapers.php?category=$1&name=$2 [QSA]
Hope this helps.

.htaccess RedirectMatch is OK to remove part from url? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I want to redirect this url:
domain.asd/category/node123/attachment/file123
to this one:
domain.asd/category/node123
by removing the attachment/fn1aa from the end.
Only the node123 and the file123 are dynamic.
The code below working, but it's valid, safe and resource-friendly?
RedirectMatch permanent category(.*)attachment /category/$1
Any recommendation are welcome. thx.
Try:
RedirectMatch permanent ^/category/([^/]+)/attachment /category/$1
It's more strict and won't duplicate forward slashes (/). Your regex will also match things like this:
domain.asd/foo/something/category/a/b/c/d/e/f/some-attachment
by redirecting to:
/category//a/b/c/d/e/f/some-
which probably isn't what you want to do. It's safe and as resource friendly as it is using an htaccess file (which is slight performance hit as opposed to putting this in the vhost config).

Rewrite a url with htaccess [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am completely new to ht-access and I am not sure that this is the correct way to do this.
On my WordPress site, I have the current url:
http://www.example.com/category/travel/
And would like to map this to:
http://www.example.com/kids-vaction-spots/
So any post under the category travel would look like:
www.example.com/kids-vaction-spots/beach-holidays
Is it possible to have a rule in the htaccess that does this?
Thank you for taking the time to look at this.
Try adding these rules to the htaccess file in your document root. Make sure they're above any rules that do routing for a CMS.
RewriteEngine On
RewriteRule ^/?category/travel/(.*)$ /kids-vacation-spots/$1 [L,R=301]

How can I append a string to an incoming url when someone visits the root of my website? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm trying to get the string /index.php?page=home behind the adress in de adressbar when people visit the root of my site.
I tried rewrite rules in .htaccess but it redirects to the .php without any css etc.
Like this:
RewriteRule (.*) index.php?page=home
I tried javascript rewrite but it reloads the page
Like this:
window.location.href = "/index.html?page=home"
My page already takes the arguments and follow a javascript function, but I would like to just simply add something to the current URL in the bar, without reloading or doing anything else.
Any ideas?
By the sound of it, you'll have to use the hash to do what you want. You can go from http://example.com/#home to http://example.com/#contact without reloading the page, but you cannot go from http://example.com/index.php?page=home to http://example.com/index.php?page=contact without reloading the page.
You can set and read from the hash using window.location.hash in javascript.

Resources