简体   繁体   English

我很难让我的 .htaccess 文件在我的远程服务器上工作

[英]I am having difficulty getting my .htaccess file to work in my remote server

please I need some help.我需要一些帮助。

I have the following codes in my .htaccess file which is working perfectly well in my local server but not working in my remote server.我的 .htaccess 文件中有以下代码,这些代码在我的本地服务器上运行良好,但在我的远程服务器上无法运行。

# Load Secure Http

RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Hide PHP extension and load php pages linked without .php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

# Disable Directory Browsing
#Options All -Indexes
Options -Indexes

I am not sure what the issue is but the second section worked well in my local server but it is not working in my remote server, that is the most obvious one.我不确定问题出在哪里,但第二部分在我的本地服务器上运行良好,但在我的远程服务器上却不起作用,这是最明显的一个。 Please what do i need to do?请问我需要做什么?

Thanks谢谢

I expected that when a file saved as filename.php and linked simply as filename is clicked, the file should be loaded but what i get is a 404 error, but once i manually add.php to the file name, it loads.我预计当文件保存为 filename.php 并简单地链接为文件名时,文件应该被加载但我得到的是 404 错误,但是一旦我手动将 .php 添加到文件名,它就会加载。

I am not sure what the issue was, i contacted my hosting provider about the issue and when i got the feeler that .htaccess should work with my hosting, I decided to do some digging and i got a code that worked online我不确定问题出在哪里,我就此问题联系了我的托管服务提供商,当我了解到 .htaccess 应该适用于我的托管服务时,我决定进行一些挖掘,并获得了一个可以在线使用的代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM