htaccess,将虚拟子域重定向到 URL 参数
我有一个 .ne.ro 域名(在罗马尼亚注册),访问者可以在其中输入或不输入“www”:
http://mydomain.ne.ro
http://www.mydomain.ne.ro
我想将 http://123.mydomain.ne.ro
重定向到 http://mydomain。 ne.ro?id=123
。如果访问者输入“www|mail|ftp”,则必须将其视为非参数(显然)。
我尝试了 使用最后一个 url 参数进行 htaccess 子域重定向 但没有成功。
当前代码:
# edited on 05/April/2011 as suggested:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.ne\.ro$
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.ne\.ro$
RewriteRule ^$ /index.php?id=%1 [R,L]
Hosted on a hostgator's business plan (linux) and registered at nic.ro, just if asking.
I have a .ne.ro domain (registered in Romania) where visitors can enter with or without 'www':
http://mydomain.ne.ro
http://www.mydomain.ne.ro
I want to redirect http://123.mydomain.ne.ro
to http://mydomain.ne.ro?id=123
. If visitor enter with 'www|mail|ftp' must be treated as non parameter (obviously).
I tried htaccess subdomain redirct with last url parameter but didn't work.
Current code:
# edited on 05/April/2011 as suggested:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.ne\.ro$
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.ne\.ro$
RewriteRule ^$ /index.php?id=%1 [R,L]
Hosted on a hostgator's business plan (linux) and registered at nic.ro, just if asking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
经过许多建议的代码(感谢 supersuphot)和大量研究,我终于找到了答案。
首先,我在 mydomain.ne.ro 下添加了子域 *,指向域文件夹/路径:
然后我使用下一个代码上传了 .htaccess 文件:
这也有效:
最重要的是 P 在最后一行改为 R,以保留原始子域。检查这个答案< /a>相关问题。
After many suggested code (thanks supersuphot) and a lot of research finally I found an answer.
First I added the subdomain * under mydomain.ne.ro, pointed to domain folder/path:
Then I uploaded .htaccess file with the next code:
this works too:
The most important thing is the P instead R at last line, to keep original subdomain. Check this answer to a related question.
哇量子!
我两天来一直在搜索该代码,呃终于...
您的第一个代码对我来说非常完美
您也可以用这个进行更改(对于大写或小写字母)
非常感谢 quantme
Wow quantme !
I'm searching that code since two days , eh finally ...
Your first code is perfect for me
Also You can change with this(for Uppercase or Lowercase letters )
Many Thanks quantme