php - htaccess 在本地主机中工作,但在 GoDaddy 中没有
问题描述
经过长时间的搜索,我终于用我需要的规则创建了一个 htaccess 文件。在本地主机中,一切正常,但在 GoDaddy 主机上,只有一半的规则有效……有人遇到同样的问题或知道如何解决吗?谢谢
# THIS IS NOT WORKING / Returns a page not found error
RewriteEngine On
RewriteRule ^/?customize/?$ all_poi.php
RewriteRule ^/?santorini/?$ santorini.php
RewriteRule ^/?aboutus/?$ aboutus.php
RewriteRule ^/??tours/?$ all_tours.php
RewriteRule ^/?tours/([0-9]+) tours.php?tour_id=$1& [L]
# Redirects to https / WORKING
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R=301,L]
#remove trailing slash / WORKING
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301] # <- for test, for prod use [L,R=301]
# Removes index.php from ExpressionEngine URLs / WORKING
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
解决方案
推荐阅读
- android - 如何销售与图书捆绑的付费应用程序?
- java - (Node.js, socket.io) JSONObject 无法转换为 int
- mysql - mysql 使用连接表和计数将动态日期从行转置到列
- sql-server - 将 Python 库导入 SQL Server
- azure-devops - 用于 Runbook 的 Azure ARM 模板,其中包含来自 Azure Git Repo 的 Powershell 文件
- javascript - JS如何更新列表项
- python-3.x - tika-python 的语言检测不起作用
- css - 底部边距对 App Bar 间距没有影响
- c++ - 将 utf16 宽 std::wstring 转换为 utf8 窄 std::string 以获取稀有字符时出现问题
- firebase - 将数组添加到 Cloud Firestore (Flutter/Dart)