Forum Moderators: phranque
rewriteEngine on
rewriteCond %{HTTP_HOST} ^(www\.seconddomain\.org¦seconddomain\.org)$
rewriteRule ^(.*)$ [primarydomain.net...] [L,R=permanent]
rewriteCond %{HTTP_HOST} ^www\.primarydomain\.net$
rewriteRule ^(.*)$ [primarydomain.net...] [L,R=permanent]
rewriteCond %{HTTP_HOST} ^primarydomain\.net$
rewriteRule ^$ /start.php
And when I add this to have index.php (this one handless all redirection and path forwarding) called I get a internal server error; bah.
rewriteCond %{HTTP_HOST}!^primarydomain\.net$
rewriteRule ^(.*)$ /index.php
If you understand the above lines properly can you please explain why it breaks it? :) In short I want it to rewrite all requests made when the domain is different from primarydomain.net to index.php so I can use the server variables and do pathforwarding. Without the last two lines: no path forwarding unless I set it up using 404 errors; but still this would not work if the path is the same as an existing file on the site itself :/
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?seconddomain\.org¦www\.primarydomain\.net
RewriteRule .* http://primarydomain.net/ [L,R=301]
RewriteCond %{HTTP_HOST} ^primarydomain\.net
RewriteRule ^$ /start.php [L]
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^primarydomain\.net
RewriteRule .* /index.php [L]
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^primarydomain\.net
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule .* /index.php [L]
I'd recommend that you *do not* end-anchor hostnames. It causes problems on some servers.
If you're still having problems, take a look at your server's raw error logs to see what the problem is -- sometimes the error log is very helpful with rewrite errors (and sometimes not).
Jim
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?seconddomain\.org¦www\.primarydomain\.net
RewriteRule .* [primarydomain.net...] [L,R=301]
-----
Actually, I dont think I can. Notice what I am using; when user enters by www.primarydomain.com/somefile I redirect to primarydomain.com/somefile, if he enters through secondarydomain.com/whatever I just redirect to primarydomain.com/ - your code does not seem to carry on the ressource to the primary domain :-)
----
This second part requires a space between "}" and "!" -- Otherwise, it looks OK. You might also want to make sure the hostname is not blank (for HTTP/1.0 requests).
----
I should have stated that in the original post, I do have a space between the } and! but for some reason it removed that space when I pasted the code :/ (edit: hmm, I put a space before this:!)
-
Your other tips are very usefull, I will try and remove end-tag tomorrow when I wake up :-) (Have no further time today)
-Bjarne
You can still use this trick to compress the www- and non-www- domains into one pattern:
RewriteCond %{HTTP_HOST} ^(www\.)?seconddomain\.org
Jim