我的网站既有WordPress文件,也有非WordPress文件。对于我的WordPress文件,.htaccess文件工作得很好。例如:https://suncatcherstudio.com/monograms/index.php get重定向到:https://suncatcherstudio.com/monograms/
但是,我的非WordPress文件不会被重定向。例如,https://suncatcherstudio.com/monogram-maker/index.php不会被重定向。我想把"index.php“去掉。实际上,将此文档重定向到:https://suncatcherstudio.com/monogram-maker/
我当前的.htaccess文件如下所示:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>一个人建议有两个.htaccess文件。但是,我不希望每次添加重定向时都必须修改两个文件。任何帮助都将不胜感激。谢谢,比尔
发布于 2019-10-07 00:38:04
解决(5小时后!)当第二次调用程序时,我的PHP程序中的以下代码导致"index.php“出现在URL的末尾。
<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>我只需将此代码替换为:
<?php echo htmlspecialchars('https://suncatcherstudio.com/monogram-maker/');?>使用PHP_SELF:
First time called: https://suncatcherstudio.com/monogram-maker/
Second time called: https://suncatcherstudio.com/monogram-maker/index.php新方法:
First time called: https://suncatcherstudio.com/monogram-maker/
Second time called: https://suncatcherstudio.com/monogram-maker/https://stackoverflow.com/questions/58252878
复制相似问题