We are trying to redirect a single page from our parent domain to a subdomain:
http://foo.com/calendar
http://www.foo.com/calendar
redirect to:
http://events.foo.com/calendar
Using cPanel redirect, it gives us this:
RewriteCond %{HTTP_HOST} ^foo\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.foo\.com$
RewriteRule ^calendar$ "http\:\/\/events\.foo\.com\/calendar\/" [R=301,L]
However, the redirect is not working.
RewriteEngine On is included at the start of the htaccess file, as it is a WordPress site.
UPDATE:
Here is the entire htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^foo\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.foo\.com$
RewriteRule ^calendar$ "http\:\/\/events\.foo\.com\/calendar\/" [R=301,L]
Related
I have a plesk server and its configured to launch Roundcube on webmail.domain.com . Also I configured my Wordpress as a multi-site to react as with anysubdomain.domain.com, but it stops the webmail subdomain to work. How do I exclude that subdomain (webmail) from been cached by Wordpress ?
This is my .htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
to EXCLUDE (sub)domains in your ".htaccess" - file, you would use something like:
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^webmail\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Hi i have a wordpress site with two subdirectories:
example.com/forum
example.com/shop
I need to display example.com/forum on subdomain like this: forum.example.com, and simmilar with /shop
I try to do this by modyfing htaccess, but no results.
The code i was added looks like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^forum.example.com
RewriteRule ^(.*)$ http://example.com/forum/$1 [L,NC,QSA]
So the whole htacces looks like this:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^forum.example.com
RewriteRule ^(.*)$ http://example.com/forum/$1 [L,NC,QSA]
But this not working.
Also i have redirect my subdomains to subdirectories on the serwer, do i need to copy htaccess to those subdirectories?
Sorry for my bad english
I was hoping someone could take a look at my htaccess setup and tell me if I'm doing something wrong. Every time I try to add in one of the numerous formats I've found to redirect my page to www, I get a redirect loop.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The above works, but it goes to the base page with no www.
I've tried the following setups, and none work.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]
</IfModule>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This is the code I add to the default .htaccess file that is setup with WordPress. To add the www I use:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^your-site.com [NC]
RewriteRule ^(.*)$ http://www.your-site.com/$1 [L,R=301]
Make sure you update WordPress Address (URL) [under general settings] as well to include www.
I have a Wordpress network setup but currently there is only one subsite with the url
/psychology
In the future there will be addition sites with
/md
/vet
but for the time being there will only be /psychology
What I want to do is have a rewrite rule in my htaccess that when a user visits the root of the site (/) it actually loads the /psychology site.
I tried adding a line like this to my htaccess
RewriteRule (.*) psychology/$1 [R,L]
but it broke the site. here is my current htaccess (basically the wordpress default for a network install)
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /ASKanALLY/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Any ideas?
You need to add the base to the RewriteRule destination. And add a condition so you don't get a redirect loop.
Adding these two lines after RewriteRule ^ - [L] should work:
RewriteCond %{REQUEST_URI} !^/ASKanALLY/psychology ## Not already viewing a psychology URL
RewriteRule ^(.*)$ /ASKanALLY/psychology/$1 [R,L] ## Redirect to psychology
Here's the complete example:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /ASKanALLY/
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !^/ASKanALLY/psychology ## Not already viewing a psychology URL
RewriteRule ^(.*)$ /ASKanALLY/psychology/$1 [R,L] ## Redirect to psychology
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
Your RewriteRule didn't work because it was matching all URLs, including ones to /psychology/foo. I'm guessing you don't have a .htaccess file under /psychology?
Try this - it'll rewrite just the root.
RewriteRule ^/$ psychology/ [r=301,L]
I'm having a minor but annoying issue with a site running WordPress 3.1.4 Multisite.
Navigating to the URI of a subpage without the "http://www" such as "abetterworldbydesign.com/2011-conference/" results in a redirect to the root "http://www.abetterworldbydesign.com".
The intent is for "abetterworldbydesign.com/2011-conference/" to redirect to "http://www.abetterworldbydesign.com/2011-conference/".
.htaccess file below (it's specific stuff for WordPress Multisite).
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress
Try adding this
RewriteCond %{HTTP_HOST} ^abetterworldbydesign.com
RewriteRule ^(.*)$ http://www.abetterworldbydesign.com/$1 [R=301,L]
at the very top, just after RewriteEngine On.