htaccess文件不起作用,可以在子文件夹中访问php文件

发布于 2025-01-23 13:52:15 字数 707 浏览 5 评论 0原文

我正在使用HTACCESS文件在我的网站项目中具有子域的较短链接。它在以前的环境中正常工作,但是现在在新的PC上(Fresh Xampp和Laragon安装),它无法按预期工作。 我希望能够访问http:// localhost/poradnik/smart(poradnik \ pages \ smart.php) 但是我遇到了404个错误,无法打开子网站。

我的.htaccess文件看起来像这样:


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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z-_0-9]+)/?$ index.php?page=$1 [L]
RewriteRule ^([a-zA-Z-_0-9]+)/([a-zA-Z-_0-9]+)?$ index.php?page=$1/$2 [L]

SetEnv BASEURL "https://localhost/poradnik/"

我的文件分支如下: 文件列表

Im using htaccess file to have shorter links for subdomains in my website project. It was working in previous envinorment just fine, but now on new PC (fresh xampp and laragon install), it's not working as intended.
I want to be able to access http://localhost/poradnik/smart (poradnik\pages\smart.php)
but i get a 404 error and the subwebsite cant be opened.

my .htaccess file looks like this:


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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z-_0-9]+)/?$ index.php?page=$1 [L]
RewriteRule ^([a-zA-Z-_0-9]+)/([a-zA-Z-_0-9]+)?$ index.php?page=$1/$2 [L]

SetEnv BASEURL "https://localhost/poradnik/"

And my file branch is as follows:
file list

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文