I needed to remove the language slug from my urls via htaccess:
(ENGLISH) https://www.mywebsite.it/en/art/architecture/
(ITALIAN) https://www.mywebsite.it/it/arte/architettura/
I've found this code into stack:
RedirectMatch 301 /it/(.) /$1
and it worked. The problem is that I have a multilanguage website, and when I do the same thing for the english language adding:
RedirectMatch 301 /en/(.) /$1
when I click on the logo, instead of going to the english home it goes to the italian one. How I can fix this avoiding the removal of the /en/ slug from the english homepage? Thanks a lot.
Related
I've added inm my htaccess this code that I've found on this website: RedirectMatch 301 /en/(.) /$1 and RedirectMatch 301 /it/(.) /$1
My problem was to remove the language from the url, and it worked.
But, because my english homepage is like https://www.mywebsite.it/en/ , when I'm in the english version of the website, and I click the logo to go to homepage, it will redirects to the italian homepage. I dont know how to fix this code adding a rule to not remove "/en/" from the homepage.
Thank a lot.
I want to redirect all my pages from categery old to category new.
http://mywebsite.com/old/page1 to http://mywebsite.com/new/page1
http://mywebsite.com/old/page2 to http://mywebsite.com/new/page2
This is not work
RewriteRule ^old/(.*) http://mywebsite.com/new/$1 [R=301,L]
found a solution
RedirectMatch 301 /old/(.*) /new/$1
I don't know much about .htaccess, but I'm trying to help a friend who recently moved his blog to Wordpress.
We need to redirect the OLD archive pages like this:
www.domain.com/2010_04_01_archive.html
www.domain.com/2010_04_02_archive.html
www.domain.com/2010_04_03_archive.html
to NEW archive pages like this:
www.domain.com/2010/04/01
www.domain.com/2010/04/02
www.domain.com/2010/04/03
I've tried everything I can find using htaccess redirect and rewrite, but again, I don't really know what I'm doing with htaccess!
Thanks so much for your help,
Amanda
OK tried this:
Turn mod_rewrite on
RewriteEngine On
RewriteRule ^([0-9]{4})([0-9]{2})([0-9]{2})_archive.html$ /$1/$2/$3 [L,R=301]
in .htaccess in the very top level folder of my site. Still, when I go to http://www.bikermetric.com/2010_04_01_archive.html, it doesn't redirect.
Just tried this too:
RedirectMatch 301 ^/([0-9]{4})([0-9]{2})([0-9]{2})_archive.html$ /$1/$2/$3
Still nothing.
You can use mod_alias or mod_rewrite here. You'll want to stick with using mod_rewrite if you already have rewrite rules (stuff that look like RewriteEngine or RewriteRule):
mod_alias:
RedirectMatch 301 ^/([0-9]{4})_([0-9]{2})_([0-9]{2})_archive.html$ /$1/$2/$3
mod_rewrite:
RewriteEngine On
RewriteRule ^([0-9]{4})_([0-9]{2})_([0-9]{2})_archive.html$ /$1/$2/$3 [L,R=301]
You'd want to add it to the htaccess file in your document root.
I'm having a problem getting an old WordPress site page to redirect to the new basic PHP site page.
Example: The old WordPress page with no extension is at http://example.com/levelone/leveltwo/pagename
The new page is at http://example.com/directory/pagename.php.
Here are several things I've tried:
redirect 301 /levelone/leveltwo/pagename http://example.com/directory/pagename.php
This did not work at all
Then I tried redirecting the directories first, then the page, like so:
RedirectMatch 301 ^/levelone/leveltwo/ http://example.com/directory/
redirect 301 /pagename http://example.com/pagename.php
This almost worked, but gave me the right URL but without the PHP extension.
I can't just redirect an old directory to a new one because there are actually many. The example is just one. The trouble seems to be going from a non-extension page to a page with the .php extension.
Here's another thing I tried:
RedirectMatch 301 ^/levelone/leveltwo/(.*)$ /directory/$1.php
redirect 301 /pagename http://example.com/pagename.php
This gave me http://example.com/directory/pagename/.php.
Solved: I got it to work with the following:
Redirect 301 /levelone/leveltwo/pagename/ http://example.com/directory/pagename.php
The problem seemed to be with the missing forward-slash after the old page name.
Try:
RedirectMatch 301 ^/levelone/leveltwo/(.*)$ /directory/$1.php
What's probably happening is the mod_alias and mod_rewrite aren't playing nice with each other. They're both in the URI-file mapping pipeline so when one does its processing, the URI (eventhough a redirect response is what's going to ultimately happen) continues to get processed, then when the redirect happens, the URI has been mangled by mod_rewrite.
You should just stick with mod_rewrite so that you can prevent any wordpress rules from doing its thing. Add these rules above any wordpress rules you have in your htaccess file:
RewriteEngine On
RewriteRule ^/?levelone/leveltwo/(.*)$ /directory/$1.php [L,R=301]
I have a site I recently upgraded. The old site had a calendar that created hundreds of pages, on the new site this has been replaced by an events page and those calendar URL's no longer exist. For months now I have been getting search engines pounding no longer existent pages like these ones.
For example:
page not found calendar-for-groups/2012-09-15/1093
page not found calendar-for-groups/2011-W09/77
page not found calendar-for-groups/2011-W27/77
page not found calendar-for-groups/2012-06-29/1093
How can I use htaccess to redirect any www.mywebsite.com/calendar-for-groups/* request to www.mywebsite.com/events?
You could use the RedirectMatch directive of mod_alias:
RedirectMatch 301 ^/calendar-for-groups/.*$ http://www.mywebsite.com/events
Or with mod_rewrite:
RewriteRule ^calendar-for-groups/ http://www.mywebsite.com/events [R=301,L]
You can do with a few rewrite rules:
RewriteEngine on
RewriteRule ^calendar-for-groups/(.*) /events [R=301,L]