对于域名市场,我想重写一些网址并将我的旧网页(在目录中)直接重定向到新网页。
对于“重写网址”,我使用了这些代码:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(.*\.php)?$
RewriteCond %{REQUEST_URI} !^/(.*\.htm)?$
RewriteCond %{REQUEST_URI} !^/(.*\.html)?$
RewriteCond %{REQUEST_URI} !^/(.*\.shtml)?$
RewriteCond %{REQUEST_URI} !^/whois/$
RewriteRule ^(.*\.*)$ /details.php?domain=$1 [qsa,l]
RewriteRule ^whois/([^/]*)$ /whoisrequest/whois.php?whois=$1 [L]
例如http://mydomain.com/test.com
url重写像http://mydomain.com/details.php?domain=test.com
- 它很好。
问题:但与此同时,重写whois url(http://mydomain.com/whois/test.com
)或将旧网页(如http://mydomain.com/domains/123/test.com
)重定向到新网页(如http://mydomain.com/test.com
})重写为…details.php?domain=…
我应该如何处理这些规则:
如果http://mydomain.com/test.com
,则重写http://mydomain.com/details.php?domain=test.com
(仅在主网站上并包含“。”[dot] - 它可以像任何东西一样。)
如果http://mydomain.com/folder1/
或更多文件夹,则“。 (点)并不重要',不会重写。
此外,将http://mydomain.com/domains/123/test.com
重定向到http://mydomain.com/test.com
答案 0 :(得分:1)
你有两个问题:
.*\..*
模式,这将使第二条规则失效。RewriteCond %{REQUEST_FILENAME} !-f
来避免重写真实文件/目录。你的规则如下:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^whois/([^/]+)/?$ /whoisrequest/whois.php?whois=$1 [L,QSA]
RewriteRule ^([^/]+)/?$ /details.php?domain=$1 [L,QSA]