如何在Codeigniter中从前端动态设置index.php之前在URL中添加一个文件名?

时间:2019-02-21 06:07:07

标签: php .htaccess codeigniter codeigniter-htaccess

1。初始URL ProjectName/English/index.php/controller1/function1

根据前端的请求

  1. ProjectName/French/index.php/controller2/function2

  2. ProjectName/German/index.php/controller3/function3

  3. ProjectName/Deutch/index.php/controller4/functioI4

我获得了htaccess代码以删除index.php,但无法获得执行上述要求的代码。

整个控制器都在一个代码点火器应用程序中。

2 个答案:

答案 0 :(得分:0)

按以下方式在routes.php中使用Routes 您的网址调用将使用法语:ProjectName / French / controller2 / function2将调用controller2的function2

/system/core/include/private/android_filesystem_config.h

答案 1 :(得分:0)

使用此代码从.htaccess文件中的网址中删除index.php。

DirectoryIndex index.php
order deny,allow
#deny from all
allow from all
#allow from 116.193.161.42 103.212.0.0/16 61.95.235.67

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
 Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<IfModule mod_headers.c>
 Header set Access-Control-Allow-Origin "*"
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]