首页 > 解决方案 > .htaccess 问题 PHP 目录

问题描述

我今天早上尝试隐藏 URL 中的 .php 扩展名,我在互联网上发现我可以编辑 .htaccess 文件。因此,我在“localhost/Myproject/fr/”目录中创建了 .htaccess 文件,从那时起,当我想转到“localhost/Myproject/fr/”时,它会在页面上返回:

'403 Forbidden , You don't have permission to access this resource.
Apache/2.4.46 (Win64) PHP/7.3.21 Server at localhost Port 80'

我删除了 .htaccess 文件,但它没有任何改变......我也尝试重新安装 WAMP,但它仍然是一样的。有人可以知道如何解决这个问题吗?我仍然可以访问我的项目中的其他目录,例如“localhost/Myproject/en/”。

总结一下:我没有 .htaccess 文件了,但问题仍然存在......

这是我在删除文件之前在互联网上找到的 .htaccess 的代码:

Options +FollowSymlinks
RewriteEngine on 

# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://localhost/site/$1 [R=301,L]

# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://localhost/site/$1 [R=301,L]

# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]

RewriteCond %{HTTP_HOST} www.site.com
RewriteRule (.*) http:// site.com$1 [L,R=301]

ErrorDocument 404 http://localhost/site/erreur

标签: apache.htaccesswamp

解决方案


推荐阅读