我怎样才能永远不会显示的index.php?例如,所有的请求到 site.com/index.php/controller 重定向在浏览器地址栏 site.com/controller
How can I never show index.php? For example, all requests to site.com/index.php/controller are redirected in the browser address bar to site.com/controller?
我目前的.htaccess删除的index.php,但是当用户直接类型的 site.com/index.php/controller 他们仍然显示在地址栏中的地址,而不是网站.COM /控制器
My current .htaccess removes index.php but when a user directly types site.com/index.php/controller they are still shown that address in the address bar as opposed to site.com/controller
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php?/ $ 1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
注:在燃烧,我已签了很多解决重定向的index.php的.htaccess线程,但我还没有找到一个永远不会显示的index.php。这里有几个... Not显示的index.php在子目录 remove index.php文件在codeigniter
NOTE: Before flaming, I have checked lots of .htaccess threads that solve redirecting index.php but I haven't found one to never show index.php. Here are a few... Not Show index.php in subdirectory remove index.php in codeigniter
推荐答案
对于任何人寻找一个更通用的解决方案:
For anyone looking for a more generalized solution:
Options +FollowSymLinks -MultiViews
#Disallow listing contents of subfolders
Options All -Indexes
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# If index or index.php requested, strip and redirect
RewriteCond %{THE_REQUEST} index(.php)?
RewriteRule ^index(.php)?$ http://yourdomain.com/ [R=301,L]
## Part 1
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
RewriteRule ^ %1 [R,L,NC]
## Part 2 - handle incoming that lacks extension (except for existing folders)
## To redirect /dir/foo to /dir/foo.php, (skip for admin or user dirs)
RewriteRule ^(admin|user)($|/) - [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
相关推荐
最新文章