简体   繁体   English

htaccess 重定向子文件夹也

[英]htaccess redirect subfolders also

I am new to htaccess rules.我是 htaccess 规则的新手。 I have tried to search about my questionm but couldn't get the answer, so I am writing the question here.我试图搜索我的问题但无法得到答案,所以我在这里写下这个问题。

I have the following htaccess file in my root folder of my php application我的 php 应用程序的根文件夹中有以下 htaccess 文件

RewriteCond %{HTTP_HOST} www.mydomain.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

Now if I add any sub-folder images/ I get the error stating "URL not found".现在,如果我添加任何子文件夹 images/ 我会收到“找不到 URL”的错误消息。 I suspect some of the htaccess rules is causing this.我怀疑某些 htaccess 规则导致了这种情况。

I would really appreciate if someone could explain me the cause.如果有人能解释我的原因,我将不胜感激。

Thank you,谢谢,

Your rewrite condition is applying every url to your domain.您的重写条件是将每个 url 应用到您的域。 What you can do exclude image files from this.你可以做什么排除图像文件。 I think using this will help我认为使用它会有所帮助

RewriteCond %{REQUEST_URI} !^(images)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM