use*_*439 0 .htaccess codeigniter
有问题删除index.php?来自网址:
http://localhost/index.php?/reset_password
Run Code Online (Sandbox Code Playgroud)
使用htaccess文件:
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
CI设置:
$config['uri_protocol'] = 'AUTO';
Run Code Online (Sandbox Code Playgroud)
我看了这里的其他线程有类似的问题,但没有一个他们的htaccess文件工作.我错过了一个设置吗?
我以前从未见过这种.htaccess设置,虽然它可能有用.我已经将这个用于我完成的每个CI项目,试试看:
<IfModule mod_rewrite.c>
RewriteEngine on
# If the start of the URL doesn't match one of these...
RewriteCond $1 !^(index\.php|robots\.txt|assets|cache|themes|uploads)
# Route through index.php
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
添加不要忘记这个config.php:
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
Run Code Online (Sandbox Code Playgroud)
请记住:这不会index.php自动从您的网址"删除" ,而是如果不存在请求通过它.如果您有硬编码链接index.php,则必须更改它们或者您需要其他.htaccess配置.如果您使用的是CI网址功能,例如base_url(),site_url()和anchor(),index.php如果您在上面的配置中将其留空,则不会使用它们.
| 归档时间: |
|
| 查看次数: |
3973 次 |
| 最近记录: |