[英]URL rewriting using .htaccess on codeigniter website
Presently, my URL is http://www.example.com/index.php/leadsadmin/login
, and I would like to change it to http://www.admin.example.com
. 目前,我的URL是http://www.example.com/index.php/leadsadmin/login
,我想将其更改为http://www.admin.example.com
。
I am using the codeigniter framework, and I tried to create a subsite like admin.example.com
and mapped the path it to h:\\root\\home\\...\\modules\\leadsadmin
, but it did not work. 我使用的是codeigniter框架,但我尝试创建一个类似admin.example.com
的子admin.example.com
并将其路径映射到h:\\root\\home\\...\\modules\\leadsadmin
,但此操作无效。
What could I do to achieve this result? 我该怎么做才能达到这个结果?
Before answering, I have a doubt in your present URL http:// www.mydomain.com/index.php/leadsadmin/login it might be http:// www.mydomain.com/leadsadmin/login 在回答之前,我对您当前的URL http:// www.mydomain.com/index.php/leadsadmin/login感到怀疑,它可能是http:// www.mydomain.com/leadsadmin/login
Ask your service provider to create subdomain admin.mydomain.com and point it to webserver IP address 要求您的服务提供商创建子域admin.mydomain.com并将其指向Web服务器IP地址
Then on apache virual host configuration add ServerAlias as follows 然后在apache虚拟主机配置中,如下添加ServerAlias
ServerAlias admin.mydomain.com // Add this line to your virtual host block.
First, you need to remove index.php from url using .htaccess file 首先,您需要使用.htaccess文件从网址中删除index.php
.htaccess file should be .htaccess文件应为
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
Then, in application/config/routes.php file, you need to write 然后,在application / config / routes.php文件中,您需要编写
switch ( $_SERVER['HTTP_HOST'] ) {
case 'www.admin.example.com':
$route['default_controller'] = "leadsadmin/login";
break;
default:
// default action
}
try this 尝试这个
RewriteEngine On
RewriteBase /your_project_name
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.