.htaccess, mod_rewrite & index.php |
[eluser]bparker[/eluser]
Hi all, I know this topic has been discussed alot, but i just seem to be unable to make apache rewrite my URLs to not need the index.php! My setup is.... General ------- OS: Ubuntu 8.10 Web Server: Apache2 (mod_rewrite: Enabled) PHP: 4 & 5 Path to CI files: /var/www/ config settings --------------- $config['base_url'] = "www.mydomain.com/"; $config['index_page'] = ""; $config['uri_protocol'] = "AUTO"; $route['default_controller'] = "maps"; /var/www/.htaccess ------------------ DirectoryIndex index.php RewriteEngine on RewriteBase / RewriteLog "/var/log/rewrite.log" RewriteCond $1 !^(index\.php|media|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] results ------- URL Result --- ------ www.mydomain.com/ OK - maps controller/index() returned www.mydomain.com/index.php/maps OK - maps controller/index() returned www.mydomain.com/maps Page not found So mod_rewrite is enabled, but doesn't appear to be doing anything usefull! I know CI is working as it work when i enter the complete URL, but when i drop the index.php/ it gives up! The only thing i cna think of which may be causing some problems, i have for example webalizer set up in the path /var/www/webalizer. could this be causing rewrite to be missed since apache may thing i am looking for a path of /var/www/maps/ ? I also have a couple of other sites enabled, for example i have phpmyadmin installed using an apache conf file to redirect to the correct path. I would imagine this is not the case since apache knows how to redirect to these since the conf file exists for them. if there is no apache conf file rule, it should use the default pathing... basically i am stuck! i have tried various combinations, and have left myself a little confused! If anyone has any ideas i would be really grateful!!!
[eluser]Thorpe Obazee[/eluser]
Try playing with the different uri protocols in the config.
[eluser]bparker[/eluser]
tried all the uri_protocol options, but no change....
[eluser]n0xie[/eluser]
How is your apache site setup? Try changing your document root to someplace else. Does it still show your welcome screen? I'm runing apache2 on Ubuntu 9.04 (upgraded from 8.10 so setup should be identical). My site setup for a general site: Code: // example.conf from one of my sites in /etc/apache2/sites-available My 'general' .htaccess taken somewhere of this forum (probably wiki): Code: <IfModule mod_rewrite.c>
[eluser]bparker[/eluser]
ok, i moved the whole site in to it's own container, now i can go to www.mydomain.com/test/ and i get the home page defined by the default routing. If i try to go to, for example www.mydomain.com/test/search i get a 404, but www.mydomain.com/test/index.php/search works fine.... I copied and pasted your .htaccess so i am surprised it didn;t work.... it's almost as if the .htaccess file is being ignored... is there an easy way to check it's being ready by apache?
[eluser]n0xie[/eluser]
if you empty your .htaccess and just put in 'asdf', the server should return an 500 internal server error.
[eluser]eoinmcg[/eluser]
double check that mod_rewrite is loaded Code: a2enmod rewrite Also try and change Code: AllowOverRide None Code: AllowOverRide All
[eluser]bparker[/eluser]
OK, i added the following to my .htaccess file RewriteEngine On # # ONLY FOR TESTING REWRITE RULES!!!!! # RewriteLog "/tmp/rewrite.log" RewriteLogLevel 9 The idea was to make sure something was happening with the .htaccess. The result is...Nothing!!! I also checked and i have AllowOverride All set. One thing i noticed is that when i set up the site in a new containing folder, i added a file to the conf.d folder called mydomain.conf, which contains the following... Alias / /webroot/search/ <DirectoryMatch /webroot/search/> Options +FollowSymLinks AllowOverride All order allow,deny allow from all <IfModule mod_php4.c> AddType application/x-httpd-php .php php_flag magic_quotes_gpc Off php_flag short_open_tag On php_flag register_globals Off php_flag register_argc_argv On php_flag track_vars On # this setting is necessary for some locales php_value mbstring.func_overload 0 php_value include_path . DirectoryIndex index.php </IfModule> </DirectoryMatch> This seems to be different to the way you mentioned above, but should this matter? it's copied from the installation of Cacti that i have for monitoring the server, but with the details changed where necessary... I don't have anything in the sites-enabled/available folders specific to this location.... Just to check however i changed all the AllowOverride None to All in the sites-available/default file, but now i get a 500 error for everything... as a test i also tried doing what noxie sugested and putting rubish in the .htaccess file, but nothing happened... I am now pretty sure it's ignoring my .htaccess file, but now the question is how should i be setting up this site for apache so it DOES read the .htaccess... Applogies for all the questions, but I must say i am so impressed at the responses so far!!!
[eluser]bparker[/eluser]
OK, made a few changes and had a small result.... I removed the /conf.d/mydomain.conf file and added the sites-available/mydomain file with the content sugested above enabled the site with a2ensite - now listed as enabled restarted apache now i get:- www.mydomain.com/ I get the home page which the codeigniter routing is set to show www.mydomain.com/search 404 www.mydomain.com/index.php 404 www.mydomain.com/index.php/search 404 so in part something is working, since it's now happily opening the default controller (called maps) and the index function inside. it's not however opening any other controller.... I have double checked my spelling and upper/lower case etc, but all seems ok.... and still no output in the /tmp/rewrite.log so here's a thought... is my rewrite REMOVING index.php/ from my url, or is it adding it? it seems to me that:- www.mydomain.com/search is invalid, but it's not inserting the index.php www.mydomain.com/index.php/search should be valid, but it's removed the index.php/ so it's no longer working.... am i right here?
|
Welcome Guest, Not a member yet? Register Sign In |