Forum Moderators: phranque
What i want: there is a site called:
mainDomain.com
running a wordpress installation in the root (httpdocs)
I added a domain alias secondDomain.com, and installed a second wordpress into httpdocs/secondDomain.
My httpdocs root htaccess looks like this:
------------------------------------------
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# here i just canonise the urls methinks
RewriteCond %{HTTP_HOST} ^www\.secondDomain\.com$
RewriteRule (.*) [secondDomain.com...] [R=301,L]
#its the real mumbojumbo here.
rewritecond %{HTTP_HOST} ^(www\.)?secondDomain\.com
rewritecond $1 !^secondDomain/
RewriteRule (.*) /secondDomain/$1 [L]
</IfModule>
# END WordPress
My htaccess in the secondDomain folder looks like this:
-------------------------------------------------------
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I think the second one is just the default wordpress stuff, i tried with "RewriteBase /secondDomain and RewriteRule . /secondDomain/index.php [L]" too...
Everything works fine, if i dont try to reach a file or a folder.
My URLS are like this:
secondDomain.com/postname
but when i do want to reach a file or folder, my URL looks like this:
secondDomain.com/secondDomain/wp-admin/ (for example).
If i understand well, this is because directorys and files handling will not be given to the index.php file by the second .htaccess.
Also, of course, my secondDomain directorys can be reached like this:
mainDomain.com/secondDomain/wp-login.php <<<-- can be reached:
secondDomain.com/secondDomain/wp-login.php
Of course, this is because the two domain is aliased. But how can i solve thatthe secondDomain directory would create a new "root" for the secondDomain.com ?
So i could reach secondDomain.com/secondDomain/wp-login.php only by secondDomain.com/wp-login.php, thus making my whole trickery transparent.
English is not my native language, and the problem is more complex than my communication skills, so if anythingis not clear, i will try to rephrase my question.
<IfModule mod_rewrite.c>
#
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
#
# here i just canonise the urls methinks
RewriteCond %{HTTP_HOST} ^www\.secondDomain\.com
RewriteRule (.*) http://secondDomain.com/$1 [R=301,L]
#
# its the real mumbojumbo here
# (Internally rewrite secondDomain hostname requests to secondDomain subdirectory)
RewriteCond %{HTTP_HOST} ^(www\.)?secondDomain\.com
RewriteCond $1 !^secondDomain/
RewriteRule (.*) /secondDomain/$1 [L]
#
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
#
</IfModule>
Jim
You are a God!
Now it works... Thank you very much.
Some details i forgot to add... the unnecessary "secondDomain" folder was there because in the wordpress installation the siteurl option contained that unnecessary folder too. But. When i tried to replace the siteurl from secondDomain.com/secondDomain/ to simply secondDomain.com, it conflicted with the mainDomain.com and the htaccess in the root document got overridden (lost).
Now i modified the siteurl value in the database, and the site works fine! No conflicts with the mainDomain.com! Thanks you.
I will try to understand what did you changed in your code to learn from my mistake, but for this very moment I am just freaking it works!
Thank you again, Mr. Morgan!
Best Regards,
John
The general procedure for best results using mod_rewrite is to put all external redirects first (rules with substitution URLs starting with "http://xyz" and/or having an [R=30x] on them), followed by all internal rewrites. The rules in each of these two groups should be ordered from most-specific patterns and conditions (those affecting one or anly a few requested URL-paths) to least-specific patterns and conditions (those affecting many or all requested URL-paths).
This prevents unexpected pattern matches, and prevents having your external redirects expose internally-rewritten filepaths as URLs.
If it wasn't clear from my rule-processing description above, mod_rewrite in .htaccess is recursive: If any rule is invoked, then rule processing is re-started from the top, in case any rules might match the newly-rewritten path. This is true whether or not the [L] flag is used, as [L] applies only on a per-pass basis in .htaccess.
Jim