0

i am currently trying to learn about clean urls. i was using windows once. i switched to ubuntu when suddenly my .htaccess seems to be not working here is my htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

so i have this url

http://localhost/index.php/my_name/

i was expecting it to say the 'my_name' string in the browser

hello my_name

but it would only work whenever i add a '?' in the uri

http://localhost/index.php?/my_name/

i am pretty sure mod_rewrite is enabled. i even checked my phpinfo()

kapitanluffy
  • 1,269
  • 7
  • 26
  • 54

2 Answers2

2

It sounds like the rewrite module is disabled. Edit your apache configuration and load the dynamic module for mod_rewrite if available. It would look like this:

LoadModule rewrite_module modules/mod_rewrite.so

If you're using Ubuntu, run sudo a2enmod rewrite to enable the module following by restarting the Apache server:

sudo /etc/init.d/apache2 restart
Lekensteyn
  • 64,486
  • 22
  • 159
  • 192
  • so i would put the LoadModule inside the httpd.conf? damn its hard being a windows user xD – kapitanluffy Oct 30 '11 at 15:18
  • @kapitanluffy What Linux distro are you using? Generally, you've indeed to put that in httpd.conf, but distros may have their own preferred configuration methods. – Lekensteyn Oct 30 '11 at 15:27
  • @kapitanluffy I've already mentioned how to enable the rewrite module for Ubuntu using `a2enmod` ("Apache 2.x ENable MODule"). Don't forget to restart the server for the changes to take effect. – Lekensteyn Oct 30 '11 at 15:32
  • i already enabled it .but it still needs a ? in order to echo the $_SERVER[QUERY_STRING] variable – kapitanluffy Oct 30 '11 at 15:58
0

Found a solution. dumped the $_SERVER variable and used the REQUEST_URI index since QUERY_STRING does not display anything. will +1 Lekensteyn's answer since it led me to the right path

kapitanluffy
  • 1,269
  • 7
  • 26
  • 54