0
我尝试将index.php和系统页面(如404.php,403.php等)重定向到它们各自的.html页面(index.html,404.html,403)。 HTML等)在ROOT目录中。Htaccess将php文件重定向到根目录中的html
问题是,在Stackoverflow上提供的建议解决方案似乎不适用于我的情况。由于技术要求,PHP文件必须保留在根目录中。
规则在.htaccess
RewriteOptions inherit
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . index.php [L]
</IfModule>
# -- concrete5 urls end --
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin *
</IfModule>
#Header set Access-Control-Allow-Origin *
这部分的工作。所有内容现在都重定向到index.html。但是,如果我访问php相关子目录(根/文件夹)中的文件夹,它也会重定向到index.html中的根目录,而不是该子目录中的index.php。 – Alex
我确定它只适用于根目录,但你可能在子目录中有其他规则,请稍等我修改它 –
它应该只在根目录下工作,让我知道你是否有.htaccess中的子文件夹或子文件夹中的任何规则 –