From /?act=view&id=NUMBER to URL
examples:
/?act=view&id=1 to http://google.com
/?act=view&id=2 to http://facebook.com/blabla
My code
Redirect 301 /?act=view&id=157 http://google.com
You can not manipulate query strings using a Redirect directive, you need to use mod-rewrite,
Try :
RewriteEngine on
#1)Redirect "?act=view&id=1" to "http://google.com/"#
RewriteCond %{THE_REQUEST} \?act=view&id=1 [NC]
RewriteRule ^ http://google.com/? [NC,L,R]
#2)Redirect "?act=view&id=2" to "http://facebook.com/"#
RewriteCond %{THE_REQUEST} \?act=view&id=2 [NC]
RewriteRule ^ http://facebook.com/? [NC,L,R]
Related
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]
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 want to redirect all links with this format
https://besthost.tn/aze/viewticket.php?tid=VARIABLE1&c=VARIABLE2
to
https://besthost.tn/client-2/?ccce=viewticket&tid=VARIABLE1&c=VARIABLE2
the VARIABLE1 and VARIABLE2 must be inchanged while the redirection.
thank you
Try :
RewriteEngine on
RewriteCond %{THE_REQUEST} /viewticket.php\?tid=([^&]+)&c=([^\s&]+) [NC]
RewriteRule ^ /client-2/?ccce=viewticket&tid=%1&c=%2 [NC,L,R]
This will work from the root and identify '/aze/viewticket.php' and then the tid=X&C=X pattern for redirection:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/aze/viewticket\.php [NC]
RewriteCond %{QUERY_STRING} ^tid=(.+)&c=(.+)
RewriteRule ^(.*)$ /client-2/?ccce=viewticket&tid=%1&c=%2 [L,R=301]
The R=301 part indicates a 301 'permanent' redirect which will be cached by the browser and is required if this is a permanent change in your website (for performance reasons).
my htaccess file has these lines:
RewriteRule ^newlink ?do=something
Redirect 301 /oldlink/ /newlink
when i write http://www.example.com/oldlink/, browser redirects to http://www.example.com/newlink?do=something
how can i trim ?do=something ??
it should redirect to /newlink; not /newlink?do=something
Don't mix mod_rewrite rules with mod_alias ones. Keep your rules using mod_rewrite itself like this:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+newlink[\s?] [NC]
RewriteRule ^ /?do=something [L,NC,QSA]
RewriteCond %{THE_REQUEST} \s/+oldlink/?[\s?] [NC]
RewriteRule ^ /newlink? [L,NC,R=302]
? in the end is for trimming any existing query string.
I have a url in my website
http://mywebsite.com/settings.php?action=invoice
I need to redirect it to
http://mywebsite.com/settings.php?action=invoice&view=all
try
RewriteEngine on
Rewritecond %{THE_REQUEST} \ /settings\.php\?action=invoice(\ |$)
rewriterule ^ /settings\.php?action=invoice&view=all [L,R]