php - Apache 重写时出现白屏
问题描述
我正在尝试使用 .htaccess 并尝试将我的 .php 重写为另一个 url,但我一直在打白屏。
我可以确认我的 apache 重写正在访问正确的文件/文件路径,并且一旦重定向我的 php 和 html 就会被读取,但是一旦 url 被重写,我的函数由于某种原因无法正常工作。或者,我使用 WordPress 永久链接将 page-shop.php 更改为https://mhspeakers.com/shop/。
我的htaccess如下:
RewriteOptions inherit
Options -Multiviews +FollowSymLinks
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 5 minutes"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 6 hours"
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
</ifModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^test$ wp-content/themes/mhspeakers.com/page-shop.php
</IfModule>
<IfModule mod_headers.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"
#Sets Access Control
Header set Access-Control-Allow-Origin 'https://mhspeakers.com/homepage'
Header set Access-Control-Allow-Origin 'https://mhspeakers.com'
Header set Access-Control-Allow-Origin 'origin'
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
这是我没有 htaccess 重写的商店页面:
https ://mhspeakers.com/shop
如果我输入下面的链接,该链接旨在将我发送到我的 page-shop.php,但是我会得到一个白页。
https://mhspeakers.com/test
这些是我的 page-shop.php 文件的前几行:
<?php
// Session Start
session_start();
// Connect Handler
include('handler/connect.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MHSpeakers Shop</title>
<meta name="viewport" content="width=device-width, intial-scale=1.0"/>
<meta name="keywords" content="Cheshire's leading speaker designer and renovator.">
<meta name="description" content="Cheshire's leading speaker designer and renovator. We buy, sell and build speakers.">
<meta property="og:image" src="" alt="Cheshire's leading speaker designer and renovator."/>
</head>
<?php get_header2(); ?>
<body>
<div class="shop-page">
<div class="shop-inner center">
<h1 class="shop-h1">Shop</h1>
..................................
有什么建议么?
解决方案
推荐阅读
- apache-spark - 如何提高 EMR 集群中的火花性能
- r - 有没有办法查看相同的用户 ID,然后在一个小时内计算条目
- ios - 为 Admob 安装 pod 后出现 Xcode 终端错误:Google 移动广告 SDK 在没有 AppMeasurement 的情况下进行了初始化
- html - 滚动表。阴影和“tr”边界半径问题
- java - 我收到这个错误,如正文所示,在 ubuntu 中构建 apk 文件时,请帮我解决这个错误
- php - 在 laravel 中获取订单产品类别
- javascript - 如何在反应中更新渲染中的属性
- php - 如何在LINUX中访问LAMPP下不同子文件夹中的多个php文件
- mysql - 使用 Node.js 和 MySQL 作为数据库导出 excel
- javascript - 使用样式函数动态改变矢量图层的样式