1

I tried to get rid of "index.php" in url using the following rewrite code.but it's not working please help me to fix this bug

# Development
RewriteEngine On
RewriteBase /mvcTestApp/blog/ciBlog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|scripts|styles|vendor|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
1
  • Can you post the Apache access/error log as well or at least tell what is not working. Commented May 17, 2014 at 7:31

4 Answers 4

1

In .htaccess file, add the following.

#Rewrite index.php
#Start using rewrite engine
RewriteEngine On
#Rewrite condition
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Whenever index.php is there in the url, it will rewrite to / automatically
RewriteRule .* index.php/$0 [PT,L]

Check this link for more detail: http://subhra.me/remove-index-php-urls-codeigniter/

Sign up to request clarification or add additional context in comments.

Comments

0

This htaccess is working for me.Try this.

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

Comments

0

Use this rule

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

missing "/" before "index.php" in last rule

or refer URL

http://ellislab.com/codeigniter/user-guide/general/urls.html

Comments

0

Here's my suite of rewrite rules for CodeIgniter. Please read the inline comments:

## Rewrite rules
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Remove the "index.php" part of URI
    # Remove access to "codeigniter" and "data" folders
    RewriteCond %{REQUEST_URI} ^(codeigniter|data).*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # Block access to "hidden" directories whose names begin with
    # a period. e.g. .git, .svn
    RewriteCond %{SCRIPT_FILENAME} -d
    RewriteCond %{SCRIPT_FILENAME} -f
    RewriteRule "(^|/)\." - [F]

    # WWW redirect
    RewriteCond %{HTTP_HOST} ^(?!www\.).*
    RewriteCond %{HTTP_HOST} ^(?!dev\.).*
    RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,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 the root index.php.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.