Forum Moderators: phranque
Options +FollowSymLinks
RewriteEngine On
#For redirect user to www.example.com if they ask for example.com
RewriteCond %{http_host} ^example.com [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,nc]
#REDIRECTION OF OLD PAGES STARTs FROM HERE
#All Categories index pages is redirecting
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /01-funny-images/pictures-of-funny-([1-3]).php[?]?[^\ ]*\ HTTP/
RewriteRule ^01-funny-images/pictures-of-funny-([1-3]).php$ http://www.example.com/funny/index-$1.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /03-info-gallery/info-gallery-([1-2]).php[?]?[^\ ]*\ HTTP/
RewriteRule ^03-info-gallery/info-gallery-([1-2]).php$ http://www.example.com/gallery/index-$1.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /02-funny-videos/super-funny-videos-1.php[?]?[^\ ]*\ HTTP/
RewriteRule ^02-funny-videos/super-funny-videos-1.php$ http://www.example.com/videos/index.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /04-short-jokes/hilarious-short-jokes-1.php[?]?[^\ ]*\ HTTP/
RewriteRule ^04-short-jokes/hilarious-short-jokes-1.php$ http://www.example.com/jokes/index.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /05-short-stories/complete-short-stories-1.php[?]?[^\ ]*\ HTTP/
RewriteRule ^05-short-stories/complete-short-stories-1.php$ http://www.example.com/stories/index.html? [R=301,L]
#All categories subpages are redirecting
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /01-funny-images/([^.]+).php[?]?[^\ ]*\ HTTP/
RewriteRule ^01-funny-images/([^.]+).php$ http://www.example.com/funny/$1.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /02-funny-videos/([^.]+).php[?]?[^\ ]*\ HTTP/
RewriteRule ^02-funny-videos/([^.]+).php$ http://www.example.com/videos/$1.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /03-info-gallery/([^.]+).php[?]?[^\ ]*\ HTTP/
RewriteRule ^03-info-gallery/([^.]+).php$ http://www.example.com/gallery/$1.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /04-short-jokes/([^.]+).php[?]?[^\ ]*\ HTTP/
RewriteRule ^04-short-jokes/([^.]+).php$ http://www.example.com/jokes/$1.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /05-short-stories/([^.]+).php[?]?[^\ ]*\ HTTP/
RewriteRule ^05-short-stories/([^.]+).php$ http://www.example.com/stories/$1.html? [R=301,L]
#All main pages are redirecting
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /06-main-pages/contact-us.php[?]?[^\ ]*\ HTTP/
RewriteRule ^06-main-pages/contact-us.php$ http://www.example.com/main/contact.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /06-main-pages/hilarious-funny.php[?]?[^\ ]*\ HTTP/
RewriteRule ^06-main-pages/hilarious-funny.php$ http://www.example.com/main/extreme-funny.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /06-main-pages/link-exchange.php[?]?[^\ ]*\ HTTP/
RewriteRule ^06-main-pages/link-exchange.php$ http://www.example.com/main/link-exchange.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /06-main-pages/link-exchange-directory.php[?]?[^\ ]*\ HTTP/
RewriteRule ^06-main-pages/link-exchange-directory.php$ http://www.example.com/main/links-directory.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /06-main-pages/privacy-policies.php[?]?[^\ ]*\ HTTP/
RewriteRule ^06-main-pages/privacy-policies.php$ http://www.example.com/main/privacy-policies.html? [R=301,L]
#Redirect GBOT to other sitemap
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /06-main-pages/site-map.xml[?]?[^\ ]*\ HTTP/
RewriteRule ^06-main-pages/site-map.xml$ http://www.example.com/main/sitemap.xml? [R=301,L]
#Redirect to index.html when ask for index.php
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.]+)/?[^\ ]*\ HTTP/
RewriteRule ^([^.]+)/$ http://www.example.com/$1/index.html? [R=301,L]
#Redirect main/page-name.html to the variable of $cat and $page so in page get this variable
RewriteRule ^main/([^.,^/]+)\.html$ /index.php?cat=main&page=$1 [L]
#Redirect funny/index.html to the variable of $cat so in page get this variable
RewriteRule ^([funny,videos,gallery,jokes,stories]+)/index\.html$ /index.php?cat=$1 [L]
#Redirect funny/index-2.html to the variable of $cat and $page_no so in page get this variable
RewriteRule ^([funny,videos,gallery,jokes,stories]+)/index\-([0-9]*)\.html$ /index.php?cat=$1&page_no=$2 [L]
#Redirect funny/id-page-name.html to the variable of $cat, $page_id and $page_link so in page get this variable
RewriteRule ^([funny,videos,gallery,jokes,stories]+)/([0-9]*)\-([^.,^/]+)\.html$ /index.php?cat=$1&page_id=$2&page_link=$3 [L]
#Redirect funny/page-name.html to the variable of $cat and $page_link so in page get this variable
RewriteRule ^([funny,videos,gallery,jokes,stories]+)/([^.,^/]+)\.html$ /index.php?cat=$1&page_link=$2 [L]
#Giving all php pages html extension
RewriteRule ^(.*)\.html$ $1.php [L]
#For redirect user to www.example.com if they ask for example.com #Redirect to index.html when ask for index.php #Redirect to index.html when ask for index.php
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.]+)/?[^\ ]*\ HTTP/
RewriteRule ^([^.]+)/$ http://www.example.com/$1/index.html? [R=301,L]