简体   繁体   English

使用htaccess更改网址

[英]Change url using htaccess

http://localhost/project_name/folder1/index.php/folder2/controller http://localhost/project_name/folder1/index.php/folder2/controller

I want to change my url to using htaccess- 我想将网址更改为使用htaccess-

http://localhost/project_name/controller http:// localhost / project_name / controller

Activate the URL-rewrite module in apache and then write rewrite rules according to your preferred behaviour. 在apache中激活URL重写模块,然后根据您的首选行为编写重写规则。

The rules for the rewrite module can be quite tricky and complex so I can really only refer you to their own documentation. 重写模块的规则可能非常棘手和复杂,因此,我实际上只能参考您自己的文档。

http://httpd.apache.org/docs/current/mod/mod_rewrite.html http://httpd.apache.org/docs/current/mod/mod_rewrite.html

Write your base_url in config file. 将您的base_url写入配置文件。 after that remove "index.php" from config file 之后,从配置文件中删除“ index.php”

i.e.$config['index_page'] = '';

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Try this code inside root .htaccess 在root .htaccess中尝试此代码

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

You can change the route url in Codeigniter. 您可以在Codeigniter中更改路线网址。 Application->config->routes.php 应用程序->配置-> routes.php

$route['controller']='folder1/index.php/folder2/controller';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM