Welcome Guest, Not a member yet? Register   Sign In
.htaccess RewriteRule doesn't work as expected
#1
Sad 
(This post was last modified: 10-02-2019, 05:59 AM by ergec.)

I tested this on a fresh Codeigniter 3.1.11 (didn't work on 3.1.10 either) and have no idea why it doesn't work


Code:
https://www.mydomain.com/welcome/index

https://www.mydomain.com/index.php/welcome/index

https://www.mydomain.com/index.php?/welcome/index


These URL are working fine directly from browser no problem with them.

Now I need to rewrite some existing static pages to codeigniter controllers. In this case just for testing codeigniter welcome page. First of all to make sure RewriteRule works as expected I tested it with a regular php file i created. And it works fine. Remember I need rewrite not redirect.

Code:
RewriteRule ^(staticpage_(?:\d+)\.html)$ myphpcode.php [L]


Code above is working fine.

Problem is when i try codeigniter instead of myphpcode.php

If I try lines below all of them returns Codeigniter's Page Not Found error.

Code:
RewriteRule ^(staticpage_(?:\d+)\.html)$ /welcome/index [L]
Code:
RewriteRule ^(staticpage_(?:\d+)\.html)$ index.php/welcome/index [L]
Code:
RewriteRule ^(staticpage_(?:\d+)\.html)$ index.php?/welcome/index [L]


If I set enable_query_strings to TRUE rewrite works but I don't want to enable it. Also config documentation clearly says that

Please note that some of the helpers won't work as expected when this feature is enabled, since CodeIgniter is designed primarily to use segment based URLs.

Any other way to rewrite existing static content to codeigniter controllers?
Reply


Messages In This Thread
.htaccess RewriteRule doesn't work as expected - by ergec - 10-01-2019, 11:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB