I'm trying to perform the following permanent redirections in .htaccess file, but I can not make them work. Can you help me?
Thank you very much. Regards!
Redirects are these:
http://www.mapfre.com.pa/productos/#39 to https://www.mapfre.com.pa/seguros-pa/seguros/seguros-salud/
http://www.mapfre.com.pa/productos#36 to https://www.mapfre.com.pa/seguros-pa/seguros/seguros-auto/
http://www.mapfre.com.pa/?post_type=corporativo&p=21 to https://www.mapfre.com.pa/seguros-pa/sobre-mapfre-panama/historia/
There's no way to make server-side redirect for URLs with an anchor #.
The last one may be done by this rule:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^post_type=corporativo&p=21$
RewriteRule ^$ /seguros-pa/sobre-mapfre-panama/historia/ [R=301,L]
Related
I'm looking for some help. I wanted to redirect the following paramters to another url, how can I make this possible? I have googled alot of other solutions but I fail to make this one work.
https://(www).website.com/reservation#!/confirm?code=a1XapXsCmlaC0
to
https://new-website.com/test/page#!/confirm?code=a1XapXsCmlaC0
Attempted code:
RewriteRule \/reservation#!\/confirm\?code=$ https://test.com/$1
"grep"-ing the code value would make it much easier.
Any help is much appreciated.
Thanks in advance
You may use this redirect rule in your site root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?website\.com$ [NC]
RewriteRule ^reservation/?$ https://test.com/test/page [L,NC,R=301]
Query string and fragment i.e. part after # will automatically be forwarded to the new URL.
Based on your shown samples, could you please try following. Where you want to redirect from (www).website.com to new-website.com in url.
Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*) [NC]
RewriteRule ^ https://new-%1/test/page#!%{REQUEST_URI} [QSA,NE,R=301,L]
I want to redirect request to sample.php if pattern was like below
sample.com/vacation
I tried this code but not work correctly, redirect all request contain vacation such as sample.com/anything/vacation
RewriteCond %{REQUEST_URI} /vacation
RewriteRule ^ /sample.php [L,R]
how can I achieve that ?
With your shown samples, could you please try following. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^vacation/?$ sample.php [NC,L]
I want to redirect specific page url only to subdomain using .htaccess rule
eg.-
http://www.domain.com/blog to http://blog.domain.com/
Thank you in advance.
Try :
RewriteEngine on
RewriteRule ^blog/$ http://blog.subdomain.com/ [L,R]
Use this:
RewriteRule ^(blog/.*)$ http://blog.domain.com/$1 [R=301,L,NC]
This will take www.domain.com/blog and change it to www.blog.domain.com
I'm trying to perform the following redirection in .htaccess file, but I can not make them work. Can you help me?
Redirect is this:
https://www.example.com/example/CL%C3%81SULA%20DE%20MUERTE%20ACCIDENTAL%20CAD220130535.pdf to https://www.example.com/example-cl/images/example.pdf
I tried this:
Redirect 301 "/example/CL%C3%81SULA%20DE%20MUERTE%20ACCIDENTAL%20CAD220130535.pdf" https://www.example.com/example-cl/images/example.pdf
Thank you very much. Regards!
You can use this rule in site root .htaccess (a level above /example/):
RewriteEngine On
RewriteRule ^example/CL\xC3\x81SULA\x20DE\x20MUERTE\x20ACCIDENTAL\x20CAD220130535\.pdf$ /example-cl/images/example.pdf [L,R=302]
This is assuming /example/.htaccess doesn't exist. If you already have /example/.htaccess then use this rule as very first rule:
RewriteEngine On
RewriteRule ^CL\xC3\x81SULA\x20DE\x20MUERTE\x20ACCIDENTAL\x20CAD220130535\.pdf$ /example-cl/images/example.pdf [L,R=302]
I answer to myself.
I was making other redirections and find a good method to use in other similar redirections.
RewriteRule "^example/CL(.*)USULA DE MUERTE ACCIDENTAL CAD220130535.pdf" https://www.example.com/example-cl/images/example.pdf
With this method, this redirection works perfect.
I need to do a 301 permanent redirect from
http://www.example.com/search.php?search=samplesearch
to
http://www.example.com/used/search.php?search=samplesearch [301]
Any help greatly appreciated. Thanks
I think you'll find your answer if you search stackoverflow for 'redirect htaccess 301'. If you want to see how it's done. Use your cPanel to create a permanent redirect and then open your htaccess file with a text editor or cpanel filemanager to view the code. Then you'll know how to mod the htaccess manually if you need to.
Use RewriteCond with %{THE_REQUEST}
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET \/search\.php\?search=samplesearch\ HTTP/ [NC]
RewriteRule ^(.*)$ /used/search.php?search=samplesearch [R=301,L]
For more information about mod_rewrite variables this site may help you:
http://www.askapache.com/tools/mod_rewrite-variables-cheatsheet.html