Redirect link with parameters using htaccess - .htaccess

I want to redirect this link:
/content/catagorie.php?item=Notariaat
To this link:
http://www.meddo.nl/vacatures/notariaat/
I used this:
Redirect /content/catagorie.php?item=Notariaat http://www.meddo.nl/vacatures/notariaat/
But it didn't work.
Thx

use this 301 redirect
Redirect 301 http://example.com/content/catagorie.php?item=Notariaat http://www.meddo.nl/vacatures/notariaat/

You can use these 2 rules in root .htaccess file:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /content/catagorie\.php\?item=([^\s&]+) [NC]
RewriteRule ^ /vacatures/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^vacatures/([^/.]+)/?$ /content/catagorie.php\?item=$1 [L,QSA,NC]

Related

Dynamic url's redirect from old to new url's using .htaccess

I want to redirect below two dynamic url from old url's to new url's using .htaccess and i have done this application using codeigniter.
1) This are the dynamic url's and there are more than thousands of url's in my database.
Old(From) URL
https://www.example.com/area-name/pangothe-263001
New(To) URL
https://www.example.com/pangothe-263001
2) This are the amp version of the above url.
Old(From) URL
https://www.example.com/amp-area-name/pangothe-263001
New(To) URL
https://www.example.com/pangothe-263001/amp
I have tried with below code
RewriteRule ^area-name$ http://www.example.com/area-name [R=301,L]
RewriteRule ^amp-area-name$ http://www.example.com/amp-area-name [R=301,L]
But not redirecting to the new urls. How can do this redirect using .htaccess.
Keep these 2 redirect rules just below RewriteEngine line:
RewriteEngine On
RewriteRule ^area-name/(.+)$ /$1 [R=301,L,NC,NE]
RewriteRule ^amp-area-name/(.+)$ /$1/amp [R=301,L,NC,NE]
# remaining rules go below this
Try This
RewriteRule ^area-name/pangothe-263001/?$ $1/pangothe-263001$2 [R=301,L]
Try with below rules,
Canonical links Redirect
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/area-name/(.*)$
AMP links Redirect
RewriteRule ^ https://www.example.com/%1 [R=301]
RewriteCond %{REQUEST_URI} ^/amp-area-name/(.*)$
RewriteRule ^ https://www.example.com/%1/amp [R=301]

How to force redirect query string URL with htaccess?

I want to redirect example.com/recipes/signup?code=OLD277 to example.com/recipes-user/register How can I achieve it via htacces?
I tried the below code in .htaccess but its not working!
Redirect /recipes/signup?code=OLD277 http://example.com/recipes-user/register
You may use this rule as your topmost rule in site root .htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} /recipes/signup\?code=OLD277\s [NC]
RewriteRule . /recipes-user/register? [R=301,L,NE]

How do i forward all urls to another url

How do I forward all URLs to another URL
So all
http://www.example.com
will go to
https://new.example.com
and
http://www.example.com/im/a/url
will forward to
https://new.example.com/im/a/url
and finally
one specific url will not forward:
http://www.example.com/im/ANOTHER/url
will stay going to
http://www.example.com/im/ANOTHER/url
in my htaccess file
In example.com / :
RewriteEngine On
Redirect permanent / http://new.example.com/
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule !^im/ANOTHER/url http://new.example.com%{REQUEST_URI} [NE,NC,R=301,L]

How can I redirect a subdomain to a specific URL?

I am updating the Iirf.ini file to redirect sub.columbia.edu to giving.columbia.edu/video.
sub.columbia.edu is already redirecting to giving.columbia.edu.
How can I go one step further to redirect it to giving.columbia.edu/video.
Important Note: I would like the URL to show as sub.columbia.edu in the browser and not as giving.columbia.edu/video
#Redirect subdomain to specific URL
RewriteCond %{HTTP_HOST} ^sub\.columbia\.edu
RewriteRule ^/$ /video
The above doesn't work. Any ideas how I should modify this?
Thank you!
You can try this and see how it works for you.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.columbia\.edu
RewriteRule ^(.*) http://giving.columbia.edu/video [L,R=301]
Or you can do a redirect, this should work also.
Redirect 301 / http://giving.columbia.edu/video

Subdomain adding a folder to .htaccess

I'm trying to redirect...
http://blog.example.org/folder/name-of-page.html
...to....
http://www.example.org/different-name-of-page.html
For my .htaccess file under blog.example.org I've added...
Redirect 301 /folder/name-of-page.html http://www.example.org/different-name-of-page.html
However, when I do this it takes me to http://www.example.org/blog/folder/different-name-of-page.html
For some reason it's auto-populating the /blog/folder/ part instead of taking me to the URL I've suggested.
Any idea on a fix?
It looks like it's interferring with rewrite rules that you have that map subdomains to folders. Use mod_rewrite instead of the Redirect directive.
Before any of your other rules, add:
RewriteCond %{HTTP_HOST} ^blog\.example\.com$ [NC]
RewriteCond %{THE_REQUEST} /folder/name-of-page\.html
RewriteRule ^ http://www.example.org/different-name-of-page.html [L,R]

Resources