问题描述
所以如果一个用户输入:www .domain1.com.au - >原始网站显示
如果用户键入:www.domain2.com.au - >,则显示为www.domain1。 com.au/second.php,但网址仍然是www.domain2.com.au。
这可以使用.htaccess吗?
当前.htaccess文件的代码段是:
RewriteCond%{HTTP_HOST} www \。 domain2\.com\.au [NC]
RewriteRule(。*)/ two [L]
RewriteCond $ 1 ^(one | two | three | four)[NC]
RewriteRule ^(。*)$ /index.php/$1 [L]
所以基本上www.domain2.com.au需要显示www.domain1.com.au/two页面,其中www.domain1.com.au/index.php/two
你可以这样做:
RewriteCond%{HTTP_HOST } ^(www \。)?doma in1\.com\.au $
RewriteCond%{REQUEST_URI}!^ / domain1
RewriteRule(。*)/ domain1 / $ 1 [L]
RewriteCond%{ HTTP_HOST} ^(www\。)?domain2\.com\.au $
RewriteCond%{REQUEST_URI}!^ / domain2
RewriteRule(。*)/ domain2 / $ 1 [L]
您的确切情况与此类似:
RewriteCond%{HTTP_HOST} ^(www\。)?domain2\.com\.au $
RewriteRule(。*)/second.php [L]
编辑现在,您已经发布了一段代码片段: / p>
RewriteCond%{HTTP_HOST} www\.domain2\.com\.au [NC]
RewriteRule 。*)/index.php/two [L]
RewriteCond $ 1 ^(one | two | three | four)[NC]
RewriteRule ^(。*)$ /index.php / $ 1 [L]
I'm trying to point a domain name to a single page, and keep the domain the same (no redirect).
So if a user types: www.domain1.com.au --> original site is shown
If a user types: www.domain2.com.au --> they are shown www.domain1.com.au/second.php, but the URL still says www.domain2.com.au.
Can this be done using .htaccess?
Snippet of current .htaccess file is:
RewriteCond %{HTTP_HOST} www\.domain2\.com\.au [NC]
RewriteRule (.*) /two [L]
RewriteCond $1 ^(one|two|three|four) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
So basically the www.domain2.com.au needs to display the www.domain1.com.au/two page, which really is www.domain1.com.au/index.php/two
You could definitely do something like this:
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com\.au$
RewriteCond %{REQUEST_URI} !^/domain1
RewriteRule (.*) /domain1/$1 [L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com\.au$
RewriteCond %{REQUEST_URI} !^/domain2
RewriteRule (.*) /domain2/$1 [L]
Your exact case would similar to this:
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com\.au$
RewriteRule (.*) /second.php [L]
Edit: Now that you've posted a snippet try this instead:
RewriteCond %{HTTP_HOST} www\.domain2\.com\.au [NC]
RewriteRule (.*) /index.php/two [L]
RewriteCond $1 ^(one|two|three|four) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
这篇关于域指向单个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!