Redirect 301 not working - .htaccess

I recently change my url and I need to make 301 redirect from:
^auto-second-hand/([A-Za-z0-9,-]+)/$ afisare-judete.php?judet=$1
to
^piata-auto/([A-Za-z0-9,-]+)/$ afisare-judete.php?judet=$1
I try
RewriteRule ^auto-second-hand/([A-Za-z0-9,-]+)/$ afisare-judete.php?judet=$1 ^piata-auto/([A-Za-z0-9,-]+)/$ afisare-judete.php?judet=$1 [L,QSA,NC,R=301]
but it's not working also tried
RedirectMatch 301 ^auto-second-hand/([A-Za-z0-9,-]+)/$ afisare-judete.php?judet=$1 ^piata-auto/([A-Za-z0-9,-]+)/$ afisare-judete.php?judet=$1
Where am I wrong? Thanks

RewriteRule ^\^auto-second-hand/\(\[A-Za-z0-9,-\]\+\)/\$ afisare-judete\.php$ /^piata-auto/([A-Za-z0-9,-]+)/$ afisare-judete.php?judet=$1 [L,R=301]
Hopefully this helps :)

Related

Redirection 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

Redirect 301 using .htaccess

I need to redirect from page
http://masterkanz.com.ua/index.php?route=product/category&path=79_103
to
http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye
Rule like
Redirect 301 /index.php?route=product/category&path=79_103 http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye
doesnt works. I read that problem can be in symbol "?". But what should I do?
Try this,
RewriteEngine On
RewriteCond %{QUERY_STRING} ^route=product/category&path=79_103$
RewriteRule ^index\.php/?$ http://masterkanz.com.ua/pishushchie-prinadlezhnosti/ruchki-sharikovye? [R=301,L]
I've tried this and it is working, you need to use {QUERY_STRING} to get the rule working.
I hope this helps.

htaccess 301 redirect /%C2%A0/

I am trying to do a 301 redirect via htaccess from http://www.domainname.co.uk/%C2%A0/ to http://www.domainname.co.uk/ but i can not get it to work
I am having a lot of trouble with the /%C2%A0/ any help with this would be great
thanks
Try:
RewriteEngine On
RewriteRule ^\xC2\xA0/?$ / [L,R=301]
Or if you have to use mod_alias:
RedirectMatch 301 ^/\xC2\xA0/?$ /

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

htaccess 301 redirect rule

I'm looking for help with making a 301 redirect for:
www.domain.com/word/* to www.domain.com/*
RewriteEngine On
RewriteRule ^/?word/(.*) http://sitename.com/$1
Redirect 301 /word /

Resources