[英]htaccess Url rewriting not working
我有一个Apache URL重写的问题,我想当用户录制这样的URL时:1: www.site.com/country/city/smthg
或2: www.site.com/country/city/smthg/fct
或3: www.site.com/country/city/smthg/fct/value
我想将网址转换为:
1: www.site.com/index.php/smthg/index/country/city
2: www.site.com/index.php/smthg/fct/country/city
3: www.site.com/index.php/smthg/fct/value/country/city
我正在使用PHP Codeigniter框架,
我试过这个,但它不起作用:
Options -Indexes
RewriteEngine on
RewriteCond $1 !^(index\.php|assets/|robots\.txt)
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)$ index.php/$3/$1/$2 [L]
RewriteCond $1 !^(index\.php|assets/|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
在.htaccess中使用它:
RewriteEngine on
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
并在application-> config-> routes.php中添加这样的路由
$route['country/(:any)/(:any)/(:any)/(:any)'] = 'ControllerName/functionName/$1/$2/$3';
将'ControllerName'和'functionName'替换为您拥有的实际名称。 $ 1,$ 2和$ 3成为函数参数。
有关详细信息CodeIgniter URI路由
试试:
Options -Indexes
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /index.php/$3/index/$1/$2 [NC,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php/$3/$4/$1/$2 [NC,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php/$3/$4/$5/$1/$2 [NC,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.