Crystallize
Crystallize

Reputation: 137

redirect old URL to new URL [codeigniter .htaccess]

My old website had trouble so I code a new one. But I cant redirect my old URL to new URL. My old URL looks like :

http://sample.com/?m=news&e=view&id=66

It already shared and SEO on google. But I completed remove old source in my host. I want when someone click in that link, it will redirect to my new page:

http://sample.com/en/news/redirect-url-66.html

But idk how to write Rule for htaccess.Can anyone tell me what should I do. This's my htaccess (default CodeIgniter htaccess):

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

Upvotes: 2

Views: 1147

Answers (2)

Alon Bilu
Alon Bilu

Reputation: 74

are you using WordPress ? because if you do there are plenty of plugins that can help you with automatic Redirects at the server-level without you needing to do all the redirects yourself which with big sites can be a pain in the butt...

Upvotes: 0

Nassim
Nassim

Reputation: 2876

old url:

http://sample.com/?m=news&e=view&id=66

new url:

http://sample.com/index.php/en/news/redirect-url-66.html 

.htaccess

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

RewriteCond  %{QUERY_STRING} m=([a-z]+) $1
RewriteCond  %{QUERY_STRING} e=(view) $2
RewriteCond  %{QUERY_STRING} id=([0-9]+) $3 
RewriteRule ^(.*)$ index.php/en/%1/redirect-url-%3.html?

Hope that works for you

Upvotes: 1

Related Questions