下面是我的$ C $下的.htaccess
RewriteEngine叙述上
重写规则(。*)的index.html
问题:当访问mydomain.com/robots.txt然后再次页面重定向到index.html的 要求:
如果(URL包含的robots.txt)然后
重定向到mydomain.com/robots.txt~~V
其他
重定向到的index.html
解决方案
试试这个:
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则(。*)的index.html
基本上,这两个的RewriteCond
告诉Apache重写URL的仅在所需的文件( -f
)或目录( -d
)不存在(即!
作为否定)
另外,如果你需要它只是为的robots.txt
您可以使用类似:
的RewriteCond%{REQUEST_URI}!^ / robots.txt的$
而不是两个的RewriteCond
以上。
Here is my code for .htaccess
RewriteEngine on
RewriteRule (.*) index.html
Problem : when visit mydomain.com/robots.txt then page again redirect to index.html Required :
if(url contain robots.txt) Then
redirect to mydomain.com/robots.txt
else
redirect to index.html
解决方案
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html
Basically, those two RewriteCond
tell apache to rewrite the URL only if the requested file (-f
) or directory (-d
) doesn't exists (the !
serves as a negation).
Alternatively, if you need it just for robots.txt
you can use something like:
RewriteCond %{REQUEST_URI} !^/robots.txt$
instead of the two RewriteCond
above.
上一篇:Modrewrite到lighttpdModrewrite、lighttpd
下一篇:codeIgniter:是否可以删除控制器和放大器;使用路由或.htaccess中的URL功能?放大器、路由、控制器、功能