Limit url_suffix in the encoder

I am using codeigniter 2.1.4 and I installed $config['url_suffix'] = ".html";

It works fine without any problems. But I found out that if I use redirect();, the function always adds url_suffixto the landing page URL. for example: site.com/login/success.html .

My question anyway is to exclude url_suffixwhen using a function redirect()? or anyway add .html without installing url_suffixin codeigniter, maybe some hack in .htaccess ??

I tried to add

RewriteEngine On
RewriteCond %{REQUEST_URI} !\.[a-zA-Z0-9]{3,4}
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ $1.html

in the htaccess file of the project, but as soon as I turn off the url_suffix variable, the framework throws an error 404. Any work around?

Thanks:)

+4
1

url_suffix config blank $config['url_suffix'] = ''; , .html .

, :

routes.php ( application/config/):

$route['blog/(.+)\.html'] = "posts/view_post/$1";
/*                           ^     ^         ^
                             |     |         |
                Controller ---   Method      --- Post SEO url or ID
*/
+5

Source: https://habr.com/ru/post/1523726/


All Articles