【发布时间】:2016-07-05 11:24:33
【问题描述】:
我的系统被锁定了... 我将 config.php 文件中的设置更改为具有带参数的 URL。 突然我有了一个产品控制器,它显示我传递 URL 参数的 id。
http://localhost:8888/mywebsite/index.php?c=product&m=index&id_product=12
这个网址现在可以工作了我想得到一个类型的网址:
http://localhost:8888/mywebsite/product/my-product-12
所以我把它放在 .htaccess 文件中:
RewriteRule ^product/([a-zA-Z0-9\-]+)-([0-9]+).html$ index.php?c=product&m=index&id_product=$2 [L]
但页面显示:请求的 URL /index.php/product/my-product-12.html 在此服务器上未找到。
我的 htaccess 文件:
#Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteRule ^product/([a-zA-Z0-9\-]+)-([0-9]+).html$ index.php?c=product&m=index&id_product=$2 [L]
我的 config.php 文件:
<?php
$config['base_url'] = 'http://localhost:8888/mywebsite/';
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';
$config['url_suffix'] = '';
$config['enable_hooks'] = TRUE;
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['rewrite_short_tags'] = FALSE;
?>
【问题讨论】:
标签: php .htaccess codeigniter mod-rewrite