I'd like to redirect demo.mydomain.net/p/ to mydomain.net/.
I saved the .htaccess on my demo.mydomain.net/p/ folder but it gives me the 500 Internal Server Error.
Here's my .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^demo\.mydomain\.net\p$ [OR]
RewriteCond %{HTTP_HOST} ^www\.demo\.mydomain\.net\p$
RewriteRule ^/?$ "http\:\/\/mydomain\.net" [R=301,L]
Can anybody help me out?
Thanks in advance!
Can you test your rules:
RewriteEngine on
RewriteCond %{HTTP_HOST} demo\.mydomain\.net$ [NC]
RewriteRule ^$ http://mydomain.net/ [R=301,L]
Related
I'm trying to redirect this URL:
https://www.sendmoneypacific.org/index.php?option=com_countries&view=details&Itemid=165&lang=en
to this URL:
https://www.sendmoneypacific.org/pacific-communities/solomon-islands.html
I've tried the following:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^option=com_countries&view=details&Itemid=165&lang=en$
RewriteRule ^/index.php$ https://www.sendmoneypacific.org/pacific-communities/solomon-islands.html? [R=301,L]
and:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteCond %{QUERY_STRING} ^option=com_countries&view=details&Itemid=165&lang=en$
RewriteRule ^(.*)$ https://www.sendmoneypacific.org/pacific-communities/solomon-islands.html? [R=301,L]
But neither work. Any help would be greatly appreciated!
I figured it out -
## https://www.sendmoneypacific.org/index.php?option=com_countries&view=details&Itemid=165&lang=en
RewriteCond %{QUERY_STRING} ^option\=com_countries&view\=details&Itemid\=165&lang\=en$
RewriteRule ^index\.php$ https://www.sendmoneypacific.org/pacific-communities/solomon-islands.html? [R=301,L]
If anyone else needs help with this
And I have a lot of subdomain:
sub1.abc.com, sub2.abc.com,.., subn.abc.com with the same directory: true-dir-1, true-dir-2, true-dir-3
I want to
If url not contains (true-dir-1, true-dir-2, true-dir-3) then redirect to subdomain
For example:
sub1.abc.com/false-dir redirect to sub1.abc.com
sub2.abc.com/false-dir redirect to sub2.abc.com
Pls help me use .htaccess to redirect it..
Thanks so much!
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub1\.abc\.com$ [NC]
RewriteRule !^true-dir-1 / [L,NC,R=302]
RewriteCond %{HTTP_HOST} ^sub2\.abc\.com$ [NC]
RewriteRule !^true-dir-2 / [L,NC,R=302]
RewriteCond %{HTTP_HOST} ^sub3\.abc\.com$ [NC]
RewriteRule !^true-dir-3 / [L,NC,R=302]
You can use that:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.abc\.com$ [NC]
RewriteRule !^%1 / [L,NC,R=302]
Change [R=302] for [R=301] when test work well.
I have this situation:
When somebody goes to www.example.com, it should display www.example.com/en/
When somebody goes to www.example.fr, it should display www.example.com/fr/
Can you help me with htaccess setup?
Thank you guys!
Simple solution for .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} www.example.fr$ [NC]
RewriteRule ^$ http://www.example.com/fr/ [L,R=301]
RewriteCond %{HTTP_HOST} www.example.com$ [NC]
RewriteRule ^$ http://www.example.com/en/ [L,R=301]
Hi i need to use this existing htaccess located on the root folder.
I now need to create a new directory /testfolder/ to become http://www.companydomain.com/testfolder/ where all the files of the root will be located.
How can I make this happen with this existing htaccess? Much appreciated your help in advance!
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !(.*)/(.*).html$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
# 301
RewriteCond %{HTTP_HOST} !^www\.companydomain\.com$ [NC]
RewriteRule .? http://www.companydomain.com%{REQUEST_URI} [R=301,L]
RewriteRule ^Sportsbooks\/(.*).html$ Sportsbooks\/$1\/ [R=301,L]
This .htaccess file will redirect http://example.com/file.html to http://example.com/folder1/file.html:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} example.com$ [NC]
RewriteCond %{HTTP_HOST} !folder1
RewriteRule ^(.*)$ http://example.com/folder1/$1 [R=301,L]
I hope this helps!
I'm trying to do something like this...
Redirect www.mysite.com/directory/* to my subdommain.mysite.com/directory/*
Please help me
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^directory/(.*)$ http://subdommain.mysite.com/directory/$1 [R=301,L]
I want like it
Try adding this to your .htaccess file if you want to redirect all requests from www.mysite.com to subdomain.mysite.com:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ http://subdomain.mysite.com/$1 [R=301,L]
Try adding this to your .htaccess file if you want to redirect only requests for /anydirectory/ from www.mysite.com/anydirectory/ to subdomain.mysite.com/anyotherdirectory/:
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^anydirectory/(.*)$ http://subdommain.mysite.com/anyotherdirectory/$1 [R=301,L]