简体   繁体   中英

.htacess redirect

This may seem like a basic question, but I am not getting how to do it. Here is the Urls below.

Old Url : http://domain.com/index.php/items/view/item_name

New Url : http://domain.com/index.php/items/details/name/item_name

How do I do a permanent redirect with this set of old and new Urls in htaccess?

Put this code in your DOCUMENT_ROOT's .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(items)/view/(.*)$ /$1/details/name/$2 [NC,L,R=301]

The following worked for me....

upload a .htaccess file to the folder where ur file exists with the following data (it should be on a new line in the htaccess file)

redirect 301 /some_dir/oldpage.htm http://www.newdomain.com/newpage.htm

and from what i read somewhere when you need to do the same for a dynamic page you can use the following

consider the page as

http://www.example.com/page.php?id=13

the redirect would be

RewriteEngine on 
RewriteCond %{QUERY_STRING} ^id=13$
RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]

here is what i got on googling for this http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM