user3501407
user3501407

Reputation: 457

htaccess paramameter with Rewriterule

example.com/category/.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteBase /category/

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]

RewriteRule ^([0-9]+)(?:/[^/]+)?/?$ load.php?cat=$1 [L,QSA]

RewriteRule ^([0-9]+)/[^/]+/[^/]+/([0-9]+)/?$ load.php?cat=$1&p=$2 [L,QSA]

example.com/category/1995/english-videos/page/2 <- this is pagination. but havent 2 number like this example.com/category/1995/english-videos/page/ i want to 301 redirect to example.com/category/1995/english-videos this url. how to do it

Upvotes: 0

Views: 30

Answers (1)

Sumurai8
Sumurai8

Reputation: 20737

To redirect within mod_rewrite, you need to define the R flag. To make it a permanent redirect, you need to set the flag to 301, like so: R=301. You already set RewriteBase, which is good. The only thing you need to do is match the url now. Replace the flag R below with R=301 after you have tested the redirect thoroughly and it all works correctly.

RewriteRule ^([0-9]+/[^/]+/)page/?$ $1 [R,L]

Upvotes: 1

Related Questions