我正在尝试使用PHP和Linux在本地构建购物车。 MySQL的。我的网站的主目录是/ Library / WebServer / Documents。我尝试设置它,以便我可以在没有index.php的情况下访问localhost / project。
这是我的htaccess:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
我的配置代码(提取,而不是整个事情):
$config['base_url'] = 'http://localhost/project/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
显然这是一个错误。即使我设法访问没有index.php的localhost /项目,我也无法查看我的控制器代码生成的页面(例如,如果我尝试转到localhost / project / welcome我收到此错误消息:'The在此服务器上找不到请求的URL /项目/欢迎。' localhost / project / welcome应该带我到我的controllers文件夹下的Welcome.php页面。
Here's a snapshot of the file structure
有人可以向我解释我的代码有什么问题吗?
答案 0 :(得分:0)
你的意思是没有.php吗?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
OR
删除此DirectoryIndex index.php! 它将index.php设置在url
后面答案 1 :(得分:0)
使用此.htaccess:
id