[英]how to skip index.php and method name in url of codeigniter 1.7.2?
我是Codeigniter 1.7.2的新手。 我想跳过index.php和站点URL的方法名称。 但是我不知道如何跳过它们。 我的网站网址看起来像-
http://localhost/mysadagi_voicetongues/index.php/deal_bazaar/PrivilegeDealsbazaar
所以我想从网址中跳过index.php和PrivilegeDealsbazaar。
请提供解决方案以解决此问题。
谢谢
我忘了说。 打开您的配置文件:application / config / config.php并更改此行
$config['index_page'] = “index.php”
至
$config['index_page'] = “”
在您应用的根目录中创建一个.htaccess文件,以便
要从您的网址中删除index.php,请使用以下.htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
隐藏控制器名称不是一个好主意,因为在路由和链接到其他功能时会遇到很多问题。
希望能帮助到你!
在CI 2.1.3上使用最新版本。可以使用.htaccess从URL隐藏index.php。 您可以使用以下.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#AddHandler application/x-httpd-php5 .php
RewriteBase /projectforlder/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
如果未在URL中指定控制器,则无法访问它。
您可以通过3个步骤进行操作:
1)与应用程序持有人并行创建.htacess文件,只需复制以下代码即可:
RewriteEngine On
RewriteBase /CodeIgniter/ /* this will be your prj name. Change it as per your directory structure*/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2)将$ config ['index_page']更改为应用程序文件夹中config.php中的空白,如下所示:
$config['index_page'] = '';
3)启用apache的“ rewrite_module”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.