hi there
i have a website develop in codeigniter framework i have upload the website in subdomain but the the problem with url rewrite. the website home page works fine oes.techpawer.com but when i open the login page or any other page it will not work like to open login page this will not work but when i add index.php then it works fine but locally my site is workin without index.php means localhost/online_exam/site/login.

what's the problem with the subdomain why this is not working

here is the htaccess file code that i have.

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /oes/

    # Removes access to the system folder by users
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    # Checks to see if the user is attempting to access a valid file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

    # Add a extension to URL
    # RewriteCond %{REQUEST_FILENAME} !-f
    # RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteRule ^(.*)$ $1.php [L,QSA]
    #  -> 

    # Force "www." in the domain name.
    # RewriteCond %{HTTP_HOST} !^www.mydomain.com$
    # RewriteRule ^(.*)$  [R=301]

</IfModule>

waiting for quick reply

Regards
Rizwan

Dani AI

Generated

this pattern (works with /index.php but not without) means the front-controller rewrite is not firing for the subdomain. Two common causes: (1) the subdomain’s vhost is ignoring .htaccess, or (2) RewriteBase is wrong when the subdomain has its own document root. Put .htaccess in the subdomain’s root (the subdomain has its own docroot, so the parent domain’s .htaccess won’t apply), set index_page to empty, and drop any folder-specific RewriteBase like /oes/. CodeIgniter’s docs call out removing index.php via .htaccess, and setting base_url explicitly is recommended so detection doesn’t get confused after moving to a subdomain. (codeigniter.com)

Try this minimal setup:

// application/config/config.php
$config['base_url']   = 'http://oes.techpawer.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
# .htaccess in the subdomain's document root
<IfModule mod_rewrite.c>
    Options -Indexes -MultiViews
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ index.php?/$1 [L,QSA]
</IfModule>

If it still fails, confirm Apache is actually reading .htaccess for the subdomain. Since Apache 2.3.9 the default is AllowOverride None, which makes Apache ignore .htaccess unless the vhost explicitly allows overrides (commonly AllowOverride All or at least AllowOverride FileInfo). On shared hosting you may need your host to enable this for the subdomain’s docroot. Also keep Options -MultiViews to prevent content negotiation from hijacking paths like /site/login. (httpd.apache.org)

@LastMitch is right that you don’t edit CodeIgniter’s system folder; just ensure the above .htaccess lives at the subdomain’s root so the rewrite applies to all CI routes.

Recommended Answers

All 3 Replies

Member Avatar for Member #949455

what's the problem with the subdomain why this is not working

I have a Codeigniter on my sub-domain and it works fine. I mean the Codeigniter folder I have on my host server is working and my admin is working fine too.

So the question is what are you doing? I'm not sure why you changing your htaccess file when you don't necessary need to do that in the first place.

waiting for quick reply

The htaccess file should be on the domain root not in the Codeigniter folder. Do you understand what I am talking about.

I have upload the htaccess file in main root folder but still get same error
actually when any page open the url would be but if i add the index.php before site/developers than it works perfectly fine but i don't want index.php

Member Avatar for Member #949455

actually when any page open the url would be but if i add the index.php before site/developers than it works perfectly fine but i don't want index.php.

Regardless you still need a index.php file in that developer folder. I don't understand why you don't want it how can you access the admin section?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.