如何删除index.php
http://103.4.217.199/~xxxx/index.php/menu
到
http://103.4.217.199/~xxxx/menu
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
不工作
答案 0 :(得分:1)
打开config.php
并执行以下更换:
$config['index_page'] = "index.php"
到
$config['index_page'] = ""
在某些情况下,uri_protocol
的默认设置无效。只需替换:
$config['uri_protocol'] ="AUTO"
与
$config['uri_protocol'] = "REQUEST_URI"
然后在.htaccess
文件中使用此内容:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
答案 1 :(得分:0)
从IP地址类型网址
运行** ----------------------- **
<ifModule mod_headers.c>
Header set Access-Control-Allow-Origin: *
</ifModule>
RewriteEngine on
RewriteBase /~xxxx/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|css|js|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
答案 2 :(得分:0)
这是我的.htaccess,适用于运行Centos + Apache和Ubuntu + apache的wamp和live linux服务器
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /path-to-code-igniter-directory/index.php/$1 [L]
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
我还在这里制作了一个关于如何做到这一点的视频
https://www.youtube.com/watch?v=v-4VkR54vLU
(跳到28:50查看.htaccess。我也把它放在视频下的说明中)
希望有所帮助