是否可以使用htaccess中的RewriteRule而不是在routes.php中使用路由来屏蔽Codeigniter中的URL(不是重定向)?
我的目标是实现以下目标:
用户可以看到的URL - > https://example.com/search/query/page
实际网址 - > https://example.com/search?q=query&p=page
到目前为止我尝试过的,没有运气:
在routes.php - > $ route [“search /(:any)/(:any)”] =“search?q = $ 1&p = $ 2”;
在.htaccess - > RewriteRule ^ search /(.*)/(.*)$ / search?q = $ 1&p = $ 2 [NC,L]
我实际上已经考虑过将整个应用程序从查询字符串迁移到URL段,但不幸的是,我必然会使用来自客户端的现有代码库,并且迁移实际上不是一种选择。
任何帮助将非常感激 :)
试试这条路线:
Options All -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]