Redirection Htaccess - .htaccess

I try to make a redirection from a dead link to a new one.
source https://www.gillespaulesnault.com/esnault%20painting/html/bluenote.htm
target https://www.gillespaulesnault.com/project/blue-note-a-la-huchette/
1st solution
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^esnault%20painting\/html\/bluenote.htm
https://www.gillespaulesnault.com/project/blue-note-a-la-huchette/ [R=301,L,NC]
</IfModule>
2nd solution
Redirect 301 ^esnault%20painting\/html\/bluenote.htm https://www.gillespaulesnault.com/project/blue-note-a-la-huchette/
Can't make it works. Thank you

You could also use RedirectMatch:
RedirectMatch 301 ^esnault%20painting\/html\/bluenote\.htm$ https://www.gillespaulesnault.com/project/blue-note-a-la-huchette/
Read more about it: https://httpd.apache.org/docs/current/mod/mod_alias.html#redirectmatch

Related

URL REWRITING : Redirect a link to the new

I am a beginner in the REWRITING URL and in fact I replaced this link http://www.downisynet.rf.gd/article.php?id=14 with http://www.downisynet.rf.gd/tutoriel/14
Yet both links are still accessible.
So I want to know how to redirect the old URL to the new one?
Here is my .htaccess code:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^tutoriel-([0-9]+) article.php?tutoriel=$1 [L]
Thank you for helping me!
You can simply 301 redirect one page to another using .htaccess. Add the following to your .htaccess file:
RewriteEngine on
Redirect 301 /article.php?id=14 http://www.downisynet.rf.gd/tutoriel/14
Modified rule for /tutoriel/any-digit to /article.php?tutoriel=any-digit
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^tutoriel\/([0-9]+)$ /article.php?tutoriel=$1 [L]

redirecting to a different directory using htaccess

I'm trying to redirect the following
/books/categories/mountain-literature/my-father-frank.html
to
/books/categories/baton-wicks/my-father-frank.html
This is the line in my .htaccess
RedirectMatch 301 /mountain-literature(.*) /books/categories/baton-wicks$1
it rewrites the url and appends this pageUrl stuff on which I don't want and the correct page doesn't load ?
books/categories/baton-wicks/my-father-frank.html?pageUrl=books/categories/mountain-literature/my-father-frank&contentType=html
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^mountain-literature/(.*)$ /baton-wicks/$1 [L,R=301]
try this or this
Redirect 301 /mountain-literature /baton-wicks
If you dont need the rewrite rule to match multiple URL's, try just hardcoding the target URL, i.e.
Options +FollowSymLinks
RewriteEngine On
RewriteRule mountain-literature/(.*) /books/categories/baton-wicks/my-father-frank.html [L,R=301]
By adding the [L] flag it should tell apache not to allow any other rules to append to the URI

htaccess 301 redirect from 5 folder to 1 folder

I want to hatcchess 301 redirect thousand plus url, which are as follows:
domain.com/blog/2014/10/20/article-one/ to domain.com/article-one/
domain.com/blog/2014/10/20/article-two/ to domain.com/article-two/
domain.com/blog/2014/10/20/article-thousand/ to domain.com/article-thousand/
Hope you will answer with clear information.
Thank you.
You can use this code in your /blog/.htaccess file:
RewriteEngine On
RewriteBase /blog/
RewriteRule ^\d{4}/\d{2}/\d{2}/(.+)$ /$1 [L,NE,R=302]
If /blog/.htaccess doesn't exist then you can use this code in your /DocumentRoot/.htaccess file:
RewriteEngine On
RewriteRule ^(blog)/\d{4}/\d{2}/\d{2}/(.+)$ /$1/$2 [L,NC,NE,R=302]
This one code work great for me.
RedirectMatch 301 /blog/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4

Redirect from one location with wilcards using htaccess

I need help with how to use the htaccess when a folder and any subfolders get redirected to a new url.
Example: http:www.mysite.com/events/a-name-of-an-event (the 'a-name-of-an-event' will vary)
to
http:www.mysite.com/fixtures/
You can use RedirectMatch directive in your DOCUMENT_ROOT/.htaccess file:
RedirectMatch 301 ^/events/ /fixtures/
OR using mod_rewrite:
RewriteEngine On
RewriteRule ^events/ /fixtures/ [L,R=301,NC]

301 redirect wrong (to server path)

I want to redirect "adm" folder to "administrator"
my .htaccess code:
Redirect 301 /adm /administrator
But i go to the url:
http://www.mywebsite.com/home2/myuser/public_html/administrator
How to do this correctly?
Can RewriteRule with flags [R=301,L] do the work? Because I go to the same page with RewriteRule or Redirect
Thanks.
So this may not be a problem of your rewrite rules but maybe something wrong about your configuration.
Anyway try a rewriterule like this:
RewriteRule ^/adm(/(.*))$ /administrator$1 [QSA,R=301,NC,L]
RedirectMatch directive would do
RedirectMatch permanent /adm(.*)$ http://www.mywebsite.com/administrator$1

Resources