需要 htaccess 帮助
我想将 http:mydomain.com 重定向到 http://www.mydomain.com。 另外,我还需要包含一个条件
RewriteCond $1 !^(index\.php|images|css|uploads|editor|albums|js|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
,并且我有重定向代码,
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,NC]
如何将这两个条件合并到一个 htaccess 文件中?
-阿伦
I want to redirect the http:mydomain.com to http//www.mydomain.com.
Also I need to include one more condition
RewriteCond $1 !^(index\.php|images|css|uploads|editor|albums|js|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
And I have redirect code as
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,NC]
How to combine these two in a single htaccess file?
-Arun
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将它们复制并粘贴到一个
.htaccess
文件中就足够了。这两者没有理由不能放在一个.htaccess
中。不过,您应该先运行 www :Copy and paste them together in one
.htaccess
file should be enough. There's no reason those two are not able to be together in one.htaccess
. You should have the www one run first though:Litso 的答案对我来说看起来是正确的,但无论如何请尝试这个..
我已经替换了 $!在第二个条件中,并从规则中删除了多余的 ^$ 锚点。
Litso's answer looks right to me but try this anyway..
I've replaced $! in the second condition and removed the redundant ^$ anchors from the rules.