欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

关于.htaccess设置

程序员文章站 2022-03-06 17:56:39
...
工程的目录是
project
public
index.php
xxxx
xxxx
想实现的功能是无论用什么url访问,比如
http://localhost/project/
http://localhost/project/aaa.php
http://localhost/project/public/bbb.php
都能够转到public下的index.php
我现在在project下和public下各有一个.htaccess

project/.htaccess


RewriteEngine On
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) public/$1 [L]




public/.htaccess


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]


要访问
http://localhost/project/public/bbb.php
可以转到index.php下,
但是
http://localhost/project/aaa.php
并不能实现,

请问,该怎么设置呀
谢谢了


回复讨论(解决方案)

没有问题
http://localhost/project/aaa.php
[PHP_SELF] => /project/public/index.php
[REDIRECT_URL] => /project/public/aaa.php
[REQUEST_URI] => /project/aaa.php

http://localhost/project/public/bbb.php
[PHP_SELF] => /project/public/index.php
[REDIRECT_URL] => /project/public/bbb.php
[REQUEST_URI] => /project/public/bbb.php

版主的意思是,这么设置没有问题是吗?
怎么我的环境不好用呢

我用了一个Slim框架,难道是这个slim的问题?

相关标签: 设置 htaccess