2014-01-06 208 views
0

我想重写一些使用mod_rewrite的网址。.htaccess重写规则问题

我想重写

localhost/exotica/pet/somePet/ 

`localhost/exotica/index.php/types/get/somePet/` 

我设法用

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

所以现在localhost/exotica/types/get/somePet作品 删除的index.php我已经尝试添加作为第一条规则

RewriteRule ^pet/([A-Za-z0-9-]+)/?$ type/get/$1 [N] 

,但它只是不工作,所以请帮助我,我不知道如何启用它

我设法通过添加路由$route['pet/(:any)'] = "type/get/$1";来解决它,但我宁愿它使用.htacess文件

+0

从'/异国情调/宠物/ somePet /'(进入SEO格式)'/珍品/ index.php文件/类型/ GET/somePet /'去是无稽之谈。充其量,你仍然必须重写成“动态”格式,比如'/exotica/index.php?types = xxxxx&op = get&name = somePet',你也可以这样做。 –

+0

所以问题解决了? – anubhava

+0

@anubhava没问题aint解决因为我想用mod重写而不是codeigniter rutes。 –

回答

0

试试你的规则,像这样以相反的顺序:

RewriteEngine On 
RewriteBase /exotica/ 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^pet/([A-Za-z0-9-]+)/?$ types/get/$1 [L] 

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

好的,现在看到更新的代码。 – anubhava