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
#2

Which url is visible in your browser?
What is the value of $config['base_url'] in application/config ?
Does your welcome controller have a function named "index"?
Reply
#3

(This post was last modified: 10-02-2019, 05:59 AM by ergec.)

(10-02-2019, 05:47 AM)Wouter60 Wrote: Which url is visible in your browser?
What is the value of $config['base_url'] in application/config ?
Does your welcome controller have a function named "index"?




All these three are visible in browser



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




Base url is







Code:
$config['base_url'] = 'https://www.mydomain.com/';




Yes welcome controller is the default one that comes with codeigniter and has index method. It displays the standard welcoming message of codeigniter. See attachment.



   
Reply




Theme © iAndrew 2016 - Forum software by © MyBB