Jump to content

301 Redirects In .htaccess


Recommended Posts

I'm trying to redirect old url's to new but I'm struggling to figure this out within my .htaccess

 

# seo redirect rules ---------------------------------------------------------------------------------------------------

RewriteRule ^latest-updates/([0-9]+)/$  /latest-videos/([0-9]+)/$/ [R=301,L,QSA]
RewriteRule ^latest-updates/$  /latest-videos/$/ [R=301,L,QSA]

# redirect all index.php to the folder root

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

# redirect all script.php/blabla to website root

RewriteRule ^.+\.php/ / [R=301,L]

# automatically add slash at the end

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !^/embed/
RewriteRule (.*) /$1/ [R=301,L]

RewriteRule ^([0-9]+)/([^/]+)/$    /videos/$1/$2/ [R=301,L]

# global ---------------------------------------------------------------------------------------------------------------

RewriteRule ^sdfsdfsdf/$            terms.php [L,QSA]
RewriteRule ^terms/$            terms.php [L,QSA]
RewriteRule ^dmca/$             dmca.php [L,QSA]
RewriteRule ^2257/$             2257.php [L,QSA]

RewriteRule ^search/([^/]+)/$   search.php?q=$1 [L,QSA]
RewriteRule ^search/$           search.php [L,QSA]

RewriteRule ^link/([^/]+)/$     redirect_cs.php?dir=$1 [L,QSA]

RewriteRule ^random_video(/)?$  redirect_random_video.php [L,QSA]
RewriteRule ^random_album(/)?$  redirect_random_album.php [L,QSA]

# posts example --------------------------------------------------------------------------------------------------------

RewriteRule ^news/$                     posts_list.php?post_type=news [L,QSA]
RewriteRule ^news/([0-9]+)/$            posts_list.php?post_type=news&from=$1 [L,QSA]
RewriteRule ^news/([0-9]+)/([^/]+)/$    view_post.php?id=$1&dir=$2 [L,QSA]
RewriteRule ^news/([^/]+)/$             view_post.php?dir=$1 [L,QSA]

# videos ---------------------------------------------------------------------------------------------------------------

RewriteRule ^latest-videos/([0-9]+)/$      videos_list_latest.php?from=$1 [L,QSA]
RewriteRule ^latest-videos/$               videos_list_latest.php [L,QSA]

 

I'm basically trying to redirect my old url /latest-updates/ to /latest-videos/

 

Can somebody explain what i'm doing wrong here?

Edited by Adulty Webmaster
/ edit
Link to comment
Share on other sites

Posted (edited)
12 hours ago, Tech Support said:

Should be these:

RewriteRule ^latest-updates/([0-9]+)/$  /latest-videos/$1/ [R=301,L,QSA]
RewriteRule ^latest-updates/$  /latest-videos/ [R=301,L,QSA]

 

I've done this but still directs to a nginx 404 page? also this is suppose to be added underneath 

# seo redirect rules

 

correct?

Edited by Adulty Webmaster
edit
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...