I got a main site using Wordpress which is set at the root of the domain.
I basically want to have a DEV version of the very same WordPress (using a copy database) in a subfolder, like /dev/
Problem I got is that when I try accessing the dev version, the main WordPress at root seems to trap the request (htaccess?) and gives a "not found" page.
Here's my htaccess at root:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# MultiLingual domain
RewriteCond %{HTTP_HOST} ^(www.)?domain-other-language\.com* [OR]
RewriteCond %{HTTP_HOST} ^(www.)?domain-other-language2\.com*
RewriteRule (.*) http://www.main-domain.com/$1?lang=en [R=permanent,L]
# Alternate domain
RewriteCond %{HTTP_HOST} ^(www.)?other-domain\.com*
RewriteRule (.*) http://www.main-domain.com/$1 [R=permanent,L]
# this doesn't seem to work
RewriteRule ^dev/$ - [PT,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Try
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# MultiLingual domain
RewriteCond %{HTTP_HOST} ^(www.)?domain-other-language\.com* [OR]
RewriteCond %{HTTP_HOST} ^(www.)?domain-other-language2\.com*
RewriteRule (.*) http://www.main-domain.com/$1?lang=en [R=permanent,L]
# Alternate domain
RewriteCond %{HTTP_HOST} ^(www.)?other-domain\.com*
RewriteRule (.*) http://www.main-domain.com/$1 [R=permanent,L]
RewriteCond %{REQUEST_URI} ^dev/
RewriteRule ^dev/.*$ - [PT]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./ /index.php [L]
</IfModule>
# END WordPress
Related
I have staging.namexx.my and staging2.namexx.my now.
for staging.made4u.my, it's using directoryA
And now, i want staging2.namexx.my to use directoryB to open wordpress
*staging.namexx.my is currently working, just need to let staging to use directoryA, and staging2 to use directoryB in same server.
I'm playing with the htaccess and google for some time but still cannot get it.
I need some help.
my htaccess in root
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(staging.)?namexx.my$
RewriteCond %{REQUEST_URI} !^/dicrectoryA/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /dicrectoryA/$1
RewriteCond %{HTTP_HOST} ^(staging.)?namexx.my$
RewriteRule ^(/)?$ dicrectoryA/index.php [L]
</IfModule>
# END WordPress
htaccess in directoryA
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dicrectoryA/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dicrectoryA/index.php [L]
</IfModule>
# END WordPress
htacesss in directoryB
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /directoryB/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /directoryB/index.php [L]
</IfModule>
# END WordPress
Thank you!
To point staging2.namexx.my to directoryB via rewrite , you could use the following rule in your root/. htaccess .
RewriteEngine on
RewriteCond %{HTTP_HOST} ^staging2\.namexx\.my$ [NC]
RewriteRule ^ /directoryB%{REQUEST_URI} [L]
Just replace staging2.namexx.my with your real domain name and keep the rule block at the top of your htaccess.
i have my main site with the next .htaccess
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?]
RewriteRule ^ /%1 [R=301,L,NE]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
and in my subdomain i just install wordpress, but the rewrite rules of my main site broke the navigation of my wordpress, how can exclude my subdomain from the rules of my main domain?
i am try this but dont work
# don't apply any rewrites to the subdomain
RewriteCond %{HTTP_HOST} ^subdomain\.mysite\.com$
RewriteRule .* - [L]
and in the .htaccess of my wordpress forlder i have this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
any idea how can fix this?
thanks in advance
Use in your main site .htaccess
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{HTTP_HOST} !^subdomain\.mysite\.com$ [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?]
RewriteRule ^ /%1 [R=301,L,NE]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{HTTP_HOST} !^subdomain\.mysite\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
I need to set up the http://domain.com/wp1/ to be shown like http://domain.com/
I have tried to set up any rewrite in the past hours, but no success :(
P.S. There is a wordpress installed in the public_html/wp1, configured to work on http://domain.com/wp1/ URL. Its .htaccess is as follows:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp1/index.php [L]
</IfModule>
# END WordPress
Thanks in tons!
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]
Changing the document root for the domain does the job.
Looking at the code, this should be working (its working for other websites/subdomains i'm working on)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R]
</IfModule>
# END WordPress
Edit: the website is on a Redirect Loop now.
Fixed it going into Wordpress settings > General > Website URL and adding "www." to the domain :)
your redirect should be first before WordPress handles the request.
like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I want to redirect all the pages of my website to a new domain with a redirect. I've managed to get it working on domain level but not on the subpages.
So olddomain.com redirects to newdomain.com but olddomain.com/contact doesn't redirect to newdomain.com. It still shows the old domain.
I've used multiple rewrites rules but none of them seem to works. Any help is much appreciated.
This is the code that I'm using right now in my .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^racentegenkanker\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.racentegenkanker\.com$
RewriteRule ^(.*)$ "http\:\/\/againstcancer\.nl\/$1" [R=301,L]
For a full website redirection, you can use this (entire) .htaccess :
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://againstcancer.nl/$1 [R=301,L]
EDIT
For two domains running side by side, with one redirecting the other :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} racentegenkanker\.com$
RewriteRule ^(.*)$ http://againstcancer.nl/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress