I want to redirect following URL
http://www.example.com/friends/view.php?l=ka&id=21903
Into this page
http://www.example.com/hello.html
How can I do this using htaccess?
You can use the following rule in htaccess :
RewriteEngine on
RewriteCond %{THE_REQUEST} \s/friends/view\.php\?l=ka&id=21903\s [NC]
RewriteRule ^ http://example.com/hello.html? [L,R]
Related
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]
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]
Is it possible to redirect with htaccess, from
http://example.com/redirect.php?url=http%3A%2F%2Fanother.com%2Fsmiley.gif
to url parameter,
http://another.com/smiley.gif
Please advice.
You can use this :
RewriteEngine on
RewriteCond %{THE_REQUEST} /redirect\.php\?url=.+([^/]+\.gif)\s [NC]
RewriteRule ^ http://another.com/%1? [NE,L,R]
This will redirect /redirect.php?url=foobar/foobar.gif to http://another.com/foobar.gif .
i want to redirect this please guide me
form
http://example.com/babycare/testimonials.php?id=7
to
http://example.com/babycare/testimonial/cat/1
To redirect
http://example.com/babycare/testimonials.php?id=7
to
http://example.com/babycare/testimonial/cat/1
You can use the following rule :
RewriteEngine on
RewriteCond %{THE_REQUEST} /babycare/testimonials\.php\?id=([0-9]+) [NC]
RewriteRule ^ /babycare/testimonial/cat/%1? [L,R]
I have a condition for url redirect like,
www.domain.com/something/anotherthing/index.php
i need the above url to redirect to
www.domain.com/something/anotherthing/
If i go to
www.domain.com/index.php/something/anotherthing
i want to redirect to
www.domain.com/something/anotherthing
i have a redirect htaccess rule for this
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php$1 [NC]
RewriteRule ^ /%1$1 [R=301,L]
But this works for the first condition but in the later it redirect me to the root page. Can anyone please help in this redirection.
Thanks in Advance.
Try something like this:
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php/?([^\ \?]*) [NC]
RewriteRule ^ %1/%2 [R=301,L]
That should handle any location of /index.php.