skip to Main Content

I need to redirect the below url

http://localhost/CodeIgniter/index.php?/Welcome/

to

http://localhost/CodeIgniter/Welcome/

and I have tried the below in .htaccess

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /(.*)index.php($| |?)
RewriteRule ^ /%1 [R=301,L]

The above code taken me to below

http://localhost/CodeIgniter/?/Welcome/

I need to remove that ? mark for avoiding duplicate urls in seo. Can anybody help me

2

Answers


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

    And you have to enable mod_rewrite
    If you are using PHP version lower than 5.2.6 -> Remove the ? from index.php

    Login or Signup to reply.
  2. You can try your code this way.

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php?/(.*)
    RewriteRule ^ /%1? [R=302,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search