my questions are simple, how can I redirect this kind of urls :
www.domain.com/?page_id=25&ID=46
to :
www.anotherdomain.com/
When I try with this :
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^/?$ "http\:anotherdomain.com\" [R=301,L]
The url is redirected to http:anotherdomain.com\?page_id=25&ID=46
And another redirection I need is to redirect this :
blog1.domain.com to anotherdomain.com knowing that there are multiple blocks.
Thanks for any help,
Best regards.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www|blog1)\.domain\.com$ [NC]
RewriteRule ^ http://www.anotherdomain.com/? [R=301,L]
Related
I have the following set up for an old domain, which works really well to mapping the old pages to the ones on the new domain.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldurl.org.uk [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldurl.org.uk [NC]
RewriteRule ^(.*)$ http://www.newurl.co.uk/$1 [L,R=301,NC]
The problem is I need to redirect the homepage to a specific page on the new URL, keeping the above in tact. Whats the best way to do this?
Thanks in advance!!
You can use:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?oldurl\.org\.uk$ [NC]
RewriteRule ^$ http://www.newurl.co.uk/specificPage [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?oldurl\.org\.uk$ [NC]
RewriteRule ^(.+)$ http://www.newurl.co.uk/$1 [L,R=301]
Basically, i'm trying to redirect all the pages like this
http://www.example.com/page-test-1/page-test-1-2/page-test-1-2-3.html
or
http://www.example.com/page-test-1/page-test-1-2.html
or
http://www.example.com/page-test-1/page-test-1-2/
to the home page :
http://www.example.com/
Here's what I've trying :
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.exmaple.com/([^.]+)/
RewriteRule ^(.*) http://www.exmaple.com/ [QSA,L,R=301]
And here's the tester I'm using : http://htaccess.madewithlove.be/
Any way I can do this ? Much appreciated.
This rule should work for you:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.exmaple\.com$ [NC]
RewriteRule ^page-test-1/.+ / [L,R=301,NC]
This will catch anything that is not /anypage.html and redirect it. You need to set the RewriteCond on the REQUEST_URI not the HTTP_HOST.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/([^/]*)\.html$
RewriteRule ^(.*) http://www.example.com/ [QSA,L,R=301]
I have searched the web all over for a good generic .htaccess script for redirecting non-www to www, and currently i'm using this:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
This works fine, but if i go to a subdomain www. will be added. Does anyone has a good working redirect .htaccess script?
Try this :
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} !^([^\.]+)\.([^\.]+)\.([a-z]{2,4})$
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
#Vince What if the requested url is something like:
http://www.abc.example.com
IMHO, I think with your method it would never be redirected to:
http://www.example.com
How about this?
# Rewrite domain
RewriteCond %{HTTP_HOST} !^www\.([a-z1-9\-]+)\.([a-z]+)$ [NC] [and]
RewriteCond %{HTTP_HOST} ([a-z1-9\-]+)\.([a-z]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1.%2/$1 [R=301,L]
Also, you guys may find these references useful:
https://www.drupal.org/node/93603
http://www.askapache.com/htaccess/modrewrite-tips-tricks.html
I am stuck on the follow htaccess situation.
I want to redirect pages to subdomains.
Url example right now;
http://domain.tld/user/foo
I need to redirect this to;
http://foo.domain.tld
The subdomain is genereated by wildcard.
I tried the follow without succes;
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.tld [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld?$
RewriteRule (.*) s/index.php?user=%1 [NC,QSA]
RewriteRule ^user/(.*) (.*) [R=301,L]
Regards,
Nick
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.tld [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld?$
RewriteRule (.*) s/index.php?user=%1 [NC,QSA]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.tld [NC]
RewriteRule ^user/([a-zA-Z0-9-.]+) http://$1.domain.tld/ [R=301,L]
ive this rules at htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^warcraft$ www.site.com/forumdisplay.php?f=480 [R=301,NE,NC,L]
issue happend when redirect warcraft its redirect to
http://www.site.com/home/site/public_html/www.site.com/forumdisplay.php?f=480
any tip ?
I suppose you want to redirect it to http://www.site.com/forumdisplay.php?f=480
If so put it in your .htaccess file:
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^warcraft$ http://www.site.com/forumdisplay.php?f=480 [R=301,NE,NC,L]
You must provide the full URL including protocol in your rule, in this case http://www.site.com/.....