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中的子文件夾或子文件夾中的任何規則 –