CodeIgniter Forums
.htaccess/mod_rewrite - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: .htaccess/mod_rewrite (/thread-60310.html)



.htaccess/mod_rewrite - El Forum - 02-26-2014

[eluser]Unknown[/eluser]
Good morning!

After I don't know how much googeling and skimming forums I've decided to try to ask for help, so you guys are my hairs last hope before ripping it off. Smile

I've been struggeling with an url problem that seems pretty common and googled my fingers sore, done loads of trial and error without any luck at all.

Anyho, I'm trying to do:
http://127.0.0.1/private_html/devsite/about/
instead of
http://127.0.0.1/private_html/devsite/index.php/about/

I get either 500-error from any page when I have RewriteBase pointed at any url besides just /, serverwise or httpwise.
When I have RewriteBase pointed to just / I can access the site but once I try http.../devsite/about/ I get an 404 error.

Sys/code info:

Tried same code on 3 different servers (with similar configurations though), all debian based with latest php/apache/mysql versions.

Apache2 is configured to allow mod_rewrite and it is enabled.

.htaccess (saved in ascii on the server)(forums wont allow me to show all code but highlight all the white and it shows, strange)
Code:
RewriteEngine On
    
#Development
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

# PHP settigs
php_flag display_errors on
php_flag display_startup_errors on
php_value error_reporting 2047
php_value memory_limit 40M
php_value max_execution_time 3600

config.php in CodeIgniter (for some reason the forum dont allow show the code but highlight all the white and it shows, strange)
Code:
$config['base_url'] = 'http://127.0.0.1/private_html/devsite/'; # Development

$config['index_page'] = '';

$config['uri_protocol'] = 'AUTO';

$config['url_suffix'] = '';

apache2 error log
Code:
[Sun Feb 23 17:17:42 2014] [alert] [client 192.168.1.105] /var/www/private_html/devsite/.htaccess: <IfModule takes one argument, Container for directives based on existance of specified modules
[Sun Feb 23 17:17:44 2014] [alert] [client 192.168.1.105] /var/www/private_html/devsite/.htaccess: <IfModule takes one argument, Container for directives based on existance of specified modules
[Sun Feb 23 17:18:00 2014] [alert] [client 192.168.1.105] /var/www/private_html/devsite/.htaccess: <IfModule takes one argument, Container for directives based on existance of specified modules
[Sun Feb 23 17:20:01 2014] [alert] [client 192.168.1.105] /var/www/private_html/devsite/.htaccess: <IfModule takes one argument, Container for directives based on existance of specified modules



.htaccess/mod_rewrite - El Forum - 02-27-2014

[eluser]CroNiX[/eluser]
Your error messages are complaining about an <IfModule>, but the htaccess you posted doesn't contain that so I think the problem is elsewhere...perhaps in your main apache.conf?

I would also urge you to learn how to create virtual servers with apache, so each one of your projects would have it's own unique domain, like 'project1.dev', 'project2.dev' instead of '127.0.0.1/some_dir/project1/' and not have to mess with a lot of this stuff. It would mimic your actual server more closely and alleviate some issues which you have to work around between development/production servers.

Those htaccess rules you have regarding the /application and /system dir are way outdated and unnecessary. You should only really need:
Code:
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

The /application and /system dir have contained their own htaccess file by default for years now which deny access directly from the URL.