I am trying to do a simple redirection, but I encounter this error, when I do the 301 redirect using the htaccess, it returns the redirect but with the value
.htaccess
RewriteRule ^clientes/(\w+)/?$ clientes.php?id=$1 [L]
Redirect 301 /clientes/juan http://google.es
result:
https://www.google.es/?id=juan&gws_rd=ssl
It's because you are mixing mod-alias (Redirect) with mod-rewrite (RewriteRule) . These are two diffrent modules with diffrent runtime behaviour .
Try using this :
RewriteRule ^clientes/juan http://google.com [L,R=301]
RewriteRule ^clientes/(\w+)/?$ clientes.php?id=$1 [L]
Clear your browser cache before testing these rules.
this working, but my problem is with this line.
Rewriterule ^videos/(.*)_(.*).html$ index.php?tag=$1&page=$2 [L,NC]
Rewriterule ^videos/(.*).html$ index.php?tag=$1 [L,NC]
RewriteRule ^/videos/juan.html https://www.dominio .com/cat/conduccion-juan/ [R=301,L]
and this not working
redirect 301 /videos/juan.html https://www.dominio.com/videos/conduccion-juan.html
thank you!
Related
I have an htaccess file with over 700 redirects and most of them are not working at all. I get a 404 page mostly even though they are on the same domain. Here's 5 of them that aren't working:
Redirect 301 /orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-1-person.html /fly-snooze-cruise/orlando-airport/
Redirect 301 /orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-2-people.html /fly-snooze-cruise/orlando-airport/
Redirect 301 /orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-3-people.html /fly-snooze-cruise/orlando-airport/
Redirect 301 /orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-4-people.html /fly-snooze-cruise/orlando-airport/
Redirect 301 /orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-5-people.html /fly-snooze-cruise/orlando-airport/
I have checked the domains Please tell me what I am doing wrong. All help is appreciated.
You can use only one:
RewriteRule ^orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-\d+-person\.html$ /fly-snooze-cruise/orlando-airport [R=301,L]
OK, I found out that the rewrite rules in the mod_rewrite section somehow messed with the redirects. So I converted the "Redirect 301"s to Rewrite Rules in mod_rewrite.c and everything is working.
RewriteRule ^orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-1-person.html$ /fly-snooze-cruise/orlando-airport [R=301,L]
RewriteRule ^orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-2-people.html$ /fly-snooze-cruise/orlando-airport [R=301,L]
RewriteRule ^orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-3-people.html$ /fly-snooze-cruise/orlando-airport [R=301,L]
RewriteRule ^orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-4-people.html$ /fly-snooze-cruise/orlando-airport [R=301,L]
RewriteRule ^orlando-airport/fly-snooze-cruise-hotel-packages-orlando-airport-5-people.html$ /fly-snooze-cruise/orlando-airport [R=301,L]
I'm trying to 301-redirect a whole website to a different extension (org to com) while I'm keeping everything after the subdomain. That works. For example: www.oldsite.org/somepage redirects to www.newsite.com/somepage.
But I want some pages be to excluded from this rule, for example /sub1/ has to redirect to /sub2/ I tried it with the following code, but it didn't work. Any thoughts on this?
RewriteEngine on
RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L]
Redirect 301 /sub1/ http://www.newsite.com/sub2
Cheers!
You can use:
RewriteEngine on
RewriteRule ^sub1(/.*)?$ http://www.newsite.com/sub2$1 [R=301,L]
RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L]
Also works for:
/sub1 -> http://www.newsite.com/sub2
/sub1/etc/etc -> http://www.newsite.com/sub2/etc/etc
I have link like this:
www.site.com/page.php?p=1
Need to rewrite it to friendly URLs in htaccess
RewriteRule ^home$ page.php?p=1
It works but now I have two active links with the same content.
Tried to add 301 redirect from old link to new but stuck in loop. Any ideas how to fix that?
Try matching against the actual request so that your rules won't loop:
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /page\.php\?p=1(&|\ |^)([^\ ]*)
RewriteRule ^page\.php$ /home?%3 [L,R=301]
# then your internal rewrite
RewriteRule ^home$ page.php?p=1
Remove the redirect on the page and handle it in the htaccess.
RewriteRule ^page\.php\?p=1$ /home [L,R=301]
This will redirect to /home and stop the redirect loop you have now.
another quick & dirty way to prevent looping in these situations i've found is to add a querystring and then check for its existence in the redirect.
RewriteCond %{QUERY_STRING} ^p=1
RewriteCond %{QUERY_STRING} !foo=bar
RewriteRule ^page\.php$ /home [NC,R=301,L]
RewriteRule ^home$ page.php?p=1&foo=bar [NC,L]
found on this site: http://answers.oreilly.com/topic/542-how-to-properly-redirect-for-maximum-seo/
Redirect 301 /page.php?p=1 www.yourwebsite.com/home?p=1 RewriteRule
^home?p=1$ /page.php?p=1
I would like to make a redirect from http://www.jobslanda.com to http://www.jobslanda.com/
I'm trying to use this code in htaccess but it is not working.
Redirect permanent /http://www.alexandria-garagedoor.com http://www.alexandria-garagedoor.com/
Try:
RewriteCond %{HTTP_HOST} ^jobslanda\.com$
RewriteRule ^(.*)$ http://www.jobslanda.com/$1 [L,R=301]
I want to
redirect http://www.mysite.com/index.php?option=com_content&view=frontpage&Itemid=1
TO
http://www.mysite.com/
Can you please show me the 301 redirect rule for htaccess?
Thanks.
I tried the following, but no luck.
RewriteCond %{QUERY_STRING} ^option=com_content&view=frontpage&Itemid=1$
RewriteRule ^/index.php$ http://www.mysite.com [L,R=301]
You can try below configuration,
RewriteCond %{QUERY_STRING} option=com_content&view=frontpage&Itemid=1
RewriteRule index\.php$ /? [L,R=301]
I tried it on my domain and it works fine. Hope this works for you too... :)
According to www.htaccessredirect.net, the code to do this would be:
Redirect 301 /index.php?option=com_content&view=frontpage&Itemid=1 /
Alternatively, you could look in to using apache's mod_rewrite module.