cannot find mod_rewrite for codeigniter [closed]

2019-09-20 16:30发布

问题:

I cannot find the mod_rewrite in the codeigniter wiki anymore? where did it go? I tried looking at this link but its not in here anymore.

回答1:

mod_rewrite is part of apache web server it not part of codeigniter this extension you use to write SEO friendly url

have look on this link which will help you to write search engine friendly urls

SEO friendly urls

to check mod_rewrite is loaded or not just put in empty php file phpinfo() call that file in browser and search for mod_rewrite to enable it search for apache httpd.conf on your apache web server conf directory if it is commented with # just remove it and restart your web server after loading server call again phpinofo and search for mod_rewrite



回答2:

Your .htaccessshould look something like this:

<IfModule mod_rewrite.c>
RewriteEngine On
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
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]
</IfModule>
<IfModule !mod_rewrite.c>
 ErrorDocument 404 index.php
</IfModule>