我有两个单独的.htaccess文件,我希望将它们融合在一起,以便始终优先执行第一次重写,这会将一些流量重定向到基于该域的https。然后,如果网址中的文件不存在,则将流量发送到php文件。这是一个网址缩短器,但是如果返回404,则显示404错误页面。
I have two separate .htaccess files that I'd like to be fused together so that the first rewrite always takes precedence, which redirects some traffic to https base which domain. Then if the file at the url does not exist, then it sends the traffic to a php file. It is a url shortener, but if that returns at 404, then it shows a 404 error page.
以下是.htaccess文件的详细内容:
Here are the bits and pieces of the .htaccess files:
下面,我相信应该将除kore.tt和korett以外的所有http流量重定向到https:
This, below, I believe should redirect all http traffic except kore.tt and korett to https:
RewriteEngine on RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^(www\.)?(kore\.tt|korett\) [NC] RewriteRule ^ %{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]这是来自网址缩短程序的东西,应该将不存在的流量发送到loader.php
This is something from the url shortener that is supposed to send traffic that doesn't exist to loader.php
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.*$ /loader.php [L] </IfModule>但是如果返回404错误。这就是简单的404错误捕获。
But then if that returns a 404 error. Then this is the simple 404 error catch.
ErrorDocument 404 /404.html推荐答案
您可以在htaccess中使用条件。还有许多创建规则的方法。看看是否可以为您工作。
You can use a condition in your htaccess. There are many more ways to create rules. See if this can work for you.
#check to see if loader.php exists on the filesystem, then do rewrite <If "-f %{DOCUMENT_ROOT} . '/loader.php'"> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.*$ /loader.php [L] </If> #otherwise redirect to 404 page <Else> RewriteEngine On RewriteRule ^ /404.html [R=404,L] </Else>更多推荐
.htacess如果文件不存在,则执行重写
发布评论