How to add "-" hyphen with some text using htaccess in url - .htaccess

I need help in redirecting a url with adding some text with a hyphen.
Following is what I want to achieve:
I want to redirect https://somesite.com/girl-dresses/singapore to https://somesite.com/female-dresses/singapore-city
I tried:
RewriteEngine On
Redirect 301 /girl-dresses/singapore https://somesite.com/female-dresses/singapore-city
But this doesn't work unfortunately.

Try add in .htaccess (high is possible) this rewrite:
RewriteEngine On
RewriteRule ^girl-dresses\/singapore$ /female-dresses/singapore-city [R=301,L]

Related

Redirect all urls which contain certain parameters to another url which follows a certain pattern

Unfortunately I didn't get it solved by myself and need to ask for help. I want to redirect all urls which follow a certain pattern (in this case it contains "reviews/category"). These URLs supposed to be redirect to another url which is made up the first one:
http://[product-url]/reviews/category/[category-url]
supposed to be redirect to
http://[product-url].html
Furthermore it shouldn't matter if you call the url with or without www.
Example:
http://example.com/ford-blues/reviews/category/cars supposed to be redirect to http://example.com/ford-blues.html
Any help would be much appreciated.
Following code isn't working
RewriteEngine On
RewriteRule ^reviews/category/?$ $1\.html [R=301,L]
Try:
RedirectMatch 301 ^(.*)/reviews/category/ /$1.html
in the htaccess file in your document root.
Or using mod_rewrite:
RewriteEngine On
RewriteRule ^(.*)/reviews/category/ /$1.html [L,R=301]

How to redirect urls starting with numbers

What will be a 301 redirect rule using htaccess to redirect urls similar to
domain.com/community/783-anystring-string/profile
to
domain.com/community/
or
any url matching this type of format
domain.com/community/123-anystring-string/...
to
domain.com/community/
Basically I want to redirect any urls domain.com/community/(starting with numbers)-string...
to domain.com/community/
You'll want to use mod_rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^community/[0-9]* /community [R=301,L]
I think. That may not work, I can't test it right now :/

.htaccess redirect with questionmark

I want to redirect certain urls matching a pattern to the site root.
I'm doing:
RedirectMatch 301 ^/ABCDE.*$ /
But whenever there is a ? in the url the resulting link is whatever is after the url. How can I redirect also urls including questionmarks?
To strip off existing query string you need to use mod_rewrite rules. Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^ABCDE.*$ /? [L,R=301,NC]

i need replace word in url using htaccess and redirect it

I need to use .htaccess file to replace a word in URL
something like this:
example URL:
http://domain.com/produts
redirect to:
http://domain.com/digital-tiles
how can i do it any idea??
That can be done in many ways as these:
Redirect 301 /products /digital-tiles
OR using RedirectMatch:
RedirectMatch 301 ^/products/?$ /digital-tiles
OR using mod_rewrite
RewriteEngine On
RewriteRule ^products/?$ /digital-tiles [L,R=301,NC]

.htaccess redirect whole site to specific url new site

I have this code in my .htaccess:
Redirect 301 / http://newurl.com/
But when I go to the site example http://url.com/demo, I redirect to http://newurl.com/demo but I want only http://www.newurl.com so everything after the slash (/) has to be cut off.
How can I do this?
Alternative solution using mod_rewrite
RewriteEngine on
RewriteRule (.*)$ http://newurl.com/ [R=301,L]

Resources