htaccess的,重定向的虚拟子域网址参数重定向、域网、参数、htaccess

2023-09-02 09:36:54 作者:墨染倾城色丶

我有一个.ne.ro域(在罗马尼亚注册的),游客可以带或不带'WWW'请输入:

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

我要重定向 http://123.mydomain.ne.ro http://mydomain.ne.ro?id= 123 。如果客人有选择。|邮箱| WWW FTP必须被视为非参数(显然)

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).

我试过htaccess子域redirct与去年URL参数,但没有奏效。

目前的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]

托管在 HostGator的商业计划(Linux版),并在的 nic.ro ,只是如果要求的

Hosted on a hostgator's business plan (linux) and registered at nic.ro, just if asking.

推荐答案

在许多建议code(感谢 supersuphot ),并做了大量的研究终于让我找到了答案。

After many suggested code (thanks supersuphot) and a lot of research finally I found an answer.

首先,我添加子域名 * 在 mydomain.ne.ro ,指出了域的文件夹/路径:

First I added the subdomain * under mydomain.ne.ro, pointed to domain folder/path:

然后我上传.htaccess文件的下一个code:

Then I uploaded .htaccess file with the next code:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.mydomain.ne.ro
RewriteCond %{HTTP_HOST} ^(.+).mydomain.ne.ro
RewriteRule ^([^/]*)$ http://mydomain.ne.ro/?id=%1 [P,L]

这也工作:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.mydomain.ne.ro$
RewriteCond %{HTTP_HOST} ^(.*).mydomain.ne.ro$
RewriteRule ^$ /index.php?id=%1 [P,L]

最重要的是在的 P 代替的的研究的的最后一行,以保持原来的子域。检查this回答到相关问题。