Domain to point to a single page

时光怂恿深爱的人放手 提交于 2019-12-11 00:09:10

问题


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


回答1:


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]



回答2:


You want to show a different site than what the URL says.

That requires proxying.

Read this: http://httpd.apache.org/docs/2.0/mod/mod_proxy.html



来源:https://stackoverflow.com/questions/1371143/domain-to-point-to-a-single-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!