i how do i change my website URL using mod_rewrite my issue is after i open my site's admin section i must write www.example.com/index.php/admin

things i want is i directly open my website like www.example.com/admin help


Here is a .htaccess file replicated in the CodeIgniter PHP framework:

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

This redirects exactly what is not index.php, robots.txt or anything within the images folder to index.php/$1, where $1 may be the URL the consumer joined.

You'll need these rules as:

  • Redirecting index.php would cause an infinte loop - http://localhost/index.php/index.php/index.php/...
  • robots.txt is a vital file that search engines like google use. It is only plain text you wouldn't want it handled because of your code.
  • You clearly wish to keep getting use of your images. Adjust this path as essential for where your static assets are situated.

Do this rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php/ index.php%{REQUEST_URI} [L]

The problem would be to exclude demands of existing files to become rewritten.