htaccess rewrite first page of pagination to original url - .htaccess

I'd like to use htaccess to rewrite or redirect all urls that have the string Page-1- and make them go to the original url. e.g.
original url : http://www.website.com/blahblah
assuming the above url is a category with many pages and user has gone to page 2 and through that page he/she wants to return to page 1. As it is now, hitting page 1 at the pagination list , it will take him/her to
http://www.website.com/blahblah/Page-1- (number of results per page)
I'd like to make all urls with Page-1- go to the original url instead
Any help will be GREATLY appreciated

Try:
RewriteEngine On
RewriteRule ^(.*)/Page-1- /$1 [L,R]

Try with QSA
RewriteEngine On
RewriteRule ^(.*)/Page-1- /$1 [L,QSA,R=301]

Related

htaccess redirect from page with specific query string

I'm new to the rewrite rules in htaccess and need some help with the following:
Page I want to redirect from:
http://example.com/webinar/?confirmed
Page I want to redirect to when a user tries to access the above URL:
http://example.com/webinar-thanks
What makes this tricky is that I will still need to access the original URL with different query strings such as:
webinar/?stats
webinar/?console
And so on. I tried to do a 301 redirect but that redirects any attempt to access the /webinar page, regardless or the query string at the end, so I guess I need some rewrite syntax?
Try:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^confirmed$
RewriteRule ^webinar/?$ /webinar-thanks [L,R]

URL Redirect and Append #Hashtag

My client has gone through a rebrand and has changed their primary URL. I need to redirect all traffic that visits old URLs and send them to the same page on the new URL and ideally append a #hashtag... the hashtag will trigger an overlay explaining the redirect. Both sites are on the same Drupal codebase and thus use the same .htaccess file.
So if someone visits:
http://oldsite.com/abc/def
They should be redirected to:
http://newsite.com/abc/def/#hashtag
Any help would be greatly appreciated.
something like this?
Though I'm no expert when it comes to htaccess trickery.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com
RewriteRule (.*) http://www.newdomain.com/$1/#hashtag [R=301,L]

301 redirect based on text to new url

I'm having a little problem with an URL. I hope you can help me out!
I have this url:
http://www.domain.com/search.html?page=shop.product_details&flypage=vmj_softy.tpl&product_id=1408&category_id=1028
This needs to be redirected to:
http://www.domain.com/search.html?page=shop.product_details&flypage=vmj_color_plus.tpl&product_id=1408&category_id=1028
The only thing that needs to be changed is the flypage=vmj_softy to flypage=vmj_color_plus
The product ID and Category ID has to be a string (at has to change on all products)
I Think I need to use apaches mod_rewrite for this, but i've tried everything but I'm not able to get this to work!
Try putting this in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=shop.product_details&flypage=vmj_softy.tpl(.*)$
RewriteRule ^/?search.html$ /search.html?page=shop.product_details&flypage=vmj_color_plus.tpl%1 [L,R=301]

php htaccess issue redirection

I hava a some problem in .htaccess..
my site url is for ex. www.example.com/
when we go to city page using dropdown..its come to index.php?city=cityname (its to be correct)
when we go to about us page it comes to be indexpage instead of about us page
city page url : www.example.com/cityname
about us url : www.example.com/about-us
below htaccess code;
when we go about us page it comes to index page
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?city=$1
RewriteRule ^about-us$ about_us.php
You need to just change the order of rewrites. So, use this:
RewriteRule ^about-us$ about_us.php
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?city=$1

Dynamic URL redirect

How to redirect my url - www.example.com/home.php?rid=888601032
to www.example.com/examplepage.php
i have tried several htaccess codes 7 Im new to htccess, I would appreciate if someone can give me the correct redirect code.
The redirect you need is incredibly simple.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(home\.php)?\?rid=888601032\ HTTP/
RewriteRule ^(home\.php)?$ http://www.example.com/examplepage.php? [R=301,L]
It redirects any root request with the RID within it.
The syntax is:
redirect accessed-file URL-to-go-to
There are 3 parts;
(1) the Redirect command,
(2) the location of the file/directory you want redirected, and
(3) the full URL of the location you want that request sent to.
These parts are separated by a single space and should be on one line.
For example, if you want to redirect users from oldfile.html in the www directory of your account, myaccount, to newpage.html, the syntax should be
redirect /~myaccount/oldfile.html http://www.indiana.edu/~myaccount/newpage.html
Put this in yout .htaccess file:
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} rid=888601032
RewriteRule ^home.php examplepage.php [R,L,QSA]
If you dont want the redirect to be visible, leave the [R] flag.
Hope this helps!
Wouldn't be better to use php to do this?
if ((int)$_GET['rid'] == 888601032) // or something like this
header('Location: examplepage.php');
It depends on what you want to do, but it would be more flexible if you want to redirect to a different page depending on the "rid" parameter, or if you want to do some operation (like setting a cookie) before redirecting the user.

Resources