Reputation: 306
I have a website with a pagination its link as the following:
page 1 url = domain.com/abcd.html/
page 2 url = domain.com/abcd/index2.html
page 3 url = domain.com/abcd/index3.html
Can all links in the website be redirected from:
page 1 url = domain.com/abcd.html/ == To page 1 url = domain.com/abcd.html/
page 2 url = domain.com/abcd/index2.html == To page 2 url = domain.com/abcd.html?pg=2
page 3 url = domain.com/abcd/index3.html == To page 3 url = domain.com/abcd.html?pg=3
using an .htaccess rule?
abcd is a dynamic categories name its have many of them and its only example for one category... what I'm looking for to make all dynamic categories to be redirected using only one line.
Thank you, Best Regards,
Upvotes: 0
Views: 554
Reputation: 1066
Assuming abcd is not a folder, to get the webpages like that you need this code
For the one is default abcd.html I think you don't need anything, because it redirect to the same page
Real address: domain.com/category_name/index2.html Rewrite address: domain.com/category_name.html?pg=2 (the one the users get it)
RewriteEngine On
RewriteRule ^(.*)\.html?pg=(.*)$ ./$1/index$2.html
Upvotes: 1
Reputation: 41219
RewriteEngine On
RewriteCond %{THE_REQUEST} /([^/]+)/index([^.]+)\.html [NC]
RewriteRule ^ /%1.html?pg=%2 [NC,R,L]
Upvotes: 1
Reputation: 18671
You can use this code in your .htaccess
:
RewriteEngine on
RewriteRule ^index(\d+)\.html$ index.html?pg=$1 [NC,L]
rewrite index3.html
to index.html?pg=3
without url change
Upvotes: 1