How to redirect all pages in folder? - .htaccess

I have some old pages and I need to redirect them.
Example:
I need to redirect from:
www.domain.com/en/customer-detail/"customer_name"
to:
www.domain.com/de/customer-detail/"customer_name"
How can I do this?
Thx

You can use a simple redirect in your site root .htaccess:
RedirectMatch 301 ^/en/(customer-detai.*)$ /de/$1

Related

Change Directory with Wildcard Redirect using RedirectMatch not working

I am trying to use a RedirectMatch to redirect all files under one directory to the main directory:
RedirectMatch 301 ^/question/.*$ https://www.sample.com/
So that if I have a URL like www.sample.com/question/what-day-is-it
It will automatically redirect to www.sample.com/what-day-is-it
The problem is when I put in the RedirectMatch like above, it redirects all URLs to the homepage: www.sample.com/question/what-day-is-it to www.sample.com
If anyone else had the same problem, a simple Redirect 301 /question / did the trick.

Friendly URL or url-rewriting

I am working on a site that uses such a url
www.domain.com/hotels/hotel-name
I would like visitors just to see
www.domain.com/hotel-name
This can probably be done in the .htaccess file with a rewrite condition but I don't know how.
Thank you for helping
You can use RedirectMatch directive :
Put the following Redirect above other rules in your htaccess file
RedirectMatch 301 ^/hotels/([^/]+)/?$ /$1
This example would redirect all files from the /hotels/ folder, if you want to redirect a particular file from that folder , you can use the following:
RedirectMatch 301 ^/hotels/(file_name)/?$ /$1
Now if a visiter enters www.example.com/hotels/hotel-name then will be externally redirected to www.example.com/hotel-name

Using .htaccess to redirect to a subfolder

I'm trying to 301 redirect from '/en' or '/en/' to '/en/home' using .htaccess, but any attempt I do results into a redirection loop '/en/home/home/home/home/home/home...'.Shouldn't it be as simple as Redirect 301 /en /en/home?
Redirect based rule keep matching /en in redirected URL as well. You can use RedirectMatch for this with regex support:
RedirectMatch 301 ^/(en)/?$ /$1/home
Also make sure to clear your browser cache when you test this.
You have to use the full URL, example:
redirect 301 /folder_wrong/name.html http://website.com/folder-right/name.html

301 redirect from htaccess

I'm trying to create permanent redirects for outdated URL's on my site.
For example I have: www.mydomain.com/?v=tv and want it have a permanent 301 redirect to www.mydomain.com/tv.php
I tried this code in my htaccess file but it did not work:
Redirect /?v=tv http://mydomain.com/tv.php
Any Help?
RewriteRule ^tv.php$ http://guessthelogo.com/?v=tv [R=301,L]
I think your missing "301" after "Redirect":
Redirect 301 /?v=tv http://guessthelogo.com/tv.php

htaccess 301 subdomain moved

I want to redirect URLs like http://www.site.gen.tr/index.php?ind=reviews&op=entry_view&iden=2381 to http://arsiv.site.gen.tr?ind=reviews&op=entry_view&iden=2381 site.
I tried using .htaccess but could not make it work. Please help.
You should put this in your .htaccess file (need to be in domain root)
RewriteEngine On
Redirect 301 http://www.site.gen.tr/index.php?ind=reviews&op=entry_view&iden=2381 http://arsiv.site.gen.tr?ind=reviews&op=entry_view&iden=2381

Resources