user2824073
user2824073

Reputation: 2485

Change last element in a Path using a Rewrite Rule


I need to create a Redirect using a Rewrite rule, which rewrites the path "/page-2" into "?start=1". For example:

http://mysite/article/page-2


Needs to be changed to:

http://mysite/article?start=1


Trying with:

RewriteRule */page-2$ ?start=1 [R=301,L]

Seems not to work. Any help ? Thanks!

Upvotes: 1

Views: 34

Answers (1)

anubhava
anubhava

Reputation: 785156

You need to use this rule in your root .htaccess:

RewriteEngine On

RewriteRule ^article/page-2/?$ /article/?start=1 [R=301,L,NC]

Reference: Apache mod_rewrite Introduction

Apache mod_rewrite Technical Details

Upvotes: 1

Related Questions