Home the right way redirect url using .htaccess
Reply: 1

the right way redirect url using .htaccess

ainodoramaaa 2
ainodoramaaa 2 Published in 2018-01-11 03:25:40Z

what is the right way to redirect page using .htaccess?

for ex i want to redirect myweb.com/dorama/901110204/todome-no-kiss--paralel to myweb.com/dorama/1101071510/todome-no-kiss--parallel

but when i try to access old link, link direct to myweb.com/dorama/1101071510/todome-no-kiss--parallel?cat=dorama&idp=901110204&post=todome-no-kiss--paralel

my full .htaccess file

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    #Redirect Dead Link
    Redirect 301 /dorama/901110204/todome-no-kiss--paralel http://www.piratefiles.org/dorama/1101071510/todome-no-kiss--parallel
    Redirect 301 /dorama/601181905/life-as-a-girl http://www.piratefiles.org/dorama/1101072233/life-as-a-girl
    Redirect 301 /dorama/801130021/todome-no-kiss http://www.piratefiles.org/dorama/1101071405/todome-no-kiss

    RewriteRule ^([A-Za-z]+)/([0-9]+)/([\w-]+)/?$    view.php?cat=$1&idp=$2&post=$3&%{QUERY_STRING}   [NC,L]
    RewriteRule ^category/([\w-]+)/?$ category.php?cat=$1&%{QUERY_STRING}   [NC,L]

    # To externally redirect /dir/abc.php to /dir/abc
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] [NC]
    RewriteRule ^ /%1 [R=301,L,NE]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.+?)/?$ $1.php [QSA,NC,L]


ErrorDocument 404 http://www.piratefiles.org/404.php
Rich Bowen
Rich Bowen Reply to 2018-01-11 14:03:07Z

RewriteRule directives "run" before Redirect ones do. Thus, if you want to force the redirections to run in a particular order, you need to convert them all to Rewrite directives.

Replace the three Redirect directives with:

RewriteRule ^dorama/(\d+)/(todome-no-kiss--paralel|life-as-a-girl|todome-no-kiss)$ http://www.piratefiles.org/$1/$2 [R=301]

Tweak as necessary, but that's the reason it's failing, and a proposed solution.

(Also, standard note here: If you have access to your main server config, .htaccess files should be avoided whenever possible. .htaccess files are for people that don't have access to the main config.)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302197 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO