Reputation: 765
I want to do 301 redirection after removing index.php in codeigniter.
htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|img|js|plugins|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
After this I added
RewriteRule /index.php?page=9-someting&txt=12 /page/1/someting#2/other [R=301,L]
but redirection does not work any help?
EDIT:
/index.php?page=9-someting&txt=12 the old site that was not written in CodeIgniter
Upvotes: 0
Views: 1641
Reputation: 20753
Move your second, more special rule before the usual CI's nice url's catch-all-and-send-to-index rule. You might also want to add NE
(as no encode) because the hashmark (#
) will be encoded otherwise.
So something like this:
RewriteEngine on
# rewrite old site url, has L so processig will stop here for matching requests.
RewriteCond %{QUERY_STRING} ^page=9-someting&txt=12$
RewriteRule index.php /page/1/someting#2/other [R=301,L,NE]
# request that fall trouhg will be sent to CI's front controller (if they are not images, css....)
RewriteCond $1 !^(index\.php|images|css|img|js|plugins|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Upvotes: 2
Reputation: 64476
Try this one in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,R=301]
</IfModule>
RewriteRule ^index.php?page=9-someting&txt=12$ /page/1/someting#2/other [R=301,L]
Upvotes: 0