【问题标题】:.htaccess url rewriting for addon domains.htaccess 为插件域重写 url
【发布时间】:2014-11-26 07:36:26
【问题描述】:

我有一个运行多个网站的虚拟主机。假设我有 xyz.com,它是这个其他网站下的主要网站,作为插件域运行。

就像我有另一个网站是 xyz2.com,它是插件域。已创建对应域 xyz2.com 的文件夹。

现在的问题是我想添加一些 .htaccess 规则,没有为根网站定义规则。我只想为作为插件域的 xyz2.com 添加规则。

我已将我的 .htaccess 放入文件夹 xyz2.com。这是我写的。

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^(www\.)?xyz2.com\.com$ [NC]

RewriteCond %{THE_REQUEST} /find\.php\?source=([^\s&]+)&destination=([^\s&]+) [NC]
RewriteRule ^ %1-%2.html? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\s]+)-([^\s]+)?.html$ find.php?source=$1&destination=$2 [L,QSA]

这不起作用我在谷歌上搜索了很多这个问题,但没有任何建议有效。请帮我解决这个问题。

【问题讨论】:

标签: php .htaccess web-hosting addon-domain


【解决方案1】:

你可以试试这个规则

RewriteEngine On
RewriteBase /xyz2.com/

RewriteCond %{HTTP_HOST} !^(www\.)?xyz2\.com$ [NC]
RewriteRule ^ - [L,R=404]

RewriteCond %{THE_REQUEST} /find\.php\?source=([^\s&]+)&destination=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ find.php?source=$1&destination=$2 [L,QSA]

【讨论】:

  • 未找到 在此服务器上未找到请求的 URL /。此外,在尝试使用 ErrorDocument 处理请求时遇到 500 Internal Server Error 错误。
  • 你能检查一下有什么问题吗。
  • 我已经对您的 htaccess 进行了一些更改,现在它可以工作了,但现在它是这种形式。 xyz2.com/Delhi%2C+IndiaNoida%2C+Uttar+Pradesh%2C+India.html,请查看我的实际帖子了解我所做的更改。我想删除 %2C+ 到 -,我该怎么做
  • 是的,因为数据包含逗号,这些是动态 url
  • 我不允许使用 cmets 部分提供长期支持,但如果数据库中的数据包含逗号,那么您必须保持原样。
猜你喜欢
  • 2011-11-07
  • 2011-05-25
  • 1970-01-01
  • 1970-01-01
  • 2014-05-15
  • 1970-01-01
  • 2013-07-18
  • 1970-01-01
相关资源
最近更新 更多