3

Yes, another one of these. I've tried everything I could find on the search with no luck.

In my httpd.conf (running centos and apache2):

<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com *.domain.com
DocumentRoot /var/www/html/domain.com
</VirtualHost>

in my htaccess in /var/www/html/domain.com:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Nothing seems to be working.

I've tried adding

RewriteBase /

I've tried switching the last line to:

RewriteRule ^(.*)$ /index.php/$1 [L]
4
  • What are you trying to achieve here? Commented Nov 10, 2012 at 22:17
  • @praseodym He's trying to take the index.php out of CodeIgniter URLs. Commented Nov 10, 2012 at 22:18
  • Correct. I'm trying to go from domain.com/index.php/features to domain.com/features Commented Nov 10, 2012 at 22:22
  • The CI directions have not helped, nor have any replies here so far. codeigniter.com/user_guide/general/urls.html Commented Nov 10, 2012 at 22:22

3 Answers 3

4

You need to make sure that in your virtual host you have:

    <Directory "/path...to directory">
        Order allow,deny
        Allow from all
        Allowoverride all
    </Directory>

    <IfModule mod_rewrite.c>
        RewriteEngine on
    </IfModule>
Sign up to request clarification or add additional context in comments.

3 Comments

Fixed. This really needs to be in the CI docs. I've seen it around, but wouldn't think any of this would affect it...
@Sheldon Kennedy It used to be in the CI documentation in the Wiki on Github. But someone took it out. Without the "Allowoverride all" part, Apache won't read your .htaccess files at all. Useful for other apps that need .htaccess files.
Thanks. I was unaware of this. I thought the one directive (AccessFileName) in the httpd.conf was to allow .htaccess
0

The rules in the original post (and in the CI user guide) can be used to allow URLs to work without /index.php/ in them, but will NOT remove /index.php/ from existing URLs.

You can set $config['index_page'] = ''; (removing index.php) in the CI config to remove index.php from CI-generated URLs.

If the original rules do not work, please give these rewrite rules a try:

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

3 Comments

He still needs changes in his httpd.conf
I don't really see why the virtualhost settings will matter. Apache will respond with a server error if RewriteEngine on fails or certain lines in .htaccess are not allowed.
Because he needs the "Allowoverride all" part or else Apache won't even read the .htaccess files.
0

Two points of advice:

1.) Be sure you are saving/editing the .htaccess file into the root of your project folder, and not the .htaccess in your /applications folder. Such that, if my applications folder was at, project/application, don't edit the project/application/.htaccess file. You need your file to be located at project/.htaccess

2.) Use the following in your .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.