This question already has answers here:
301 Redirect for Query String on Root?
(2 answers)
RewriteRule redirect URL with query string in htaccess
(1 answer)
Closed 6 months ago.
I'm trying to redirect all pages containing "?s=&check_in="
Example:
/?s=&check_in=Sun%2C+04+Sep+2022&check_out=Wed%2C+07+Sep+2022&amount=1&guests=1+Adult&adult=1&children=0&infant=0
To the same new page.
I've added the following to htaccess.
RewriteEngine On
RewriteRule ^s=&check_in=(.*)$ https://app.thebookingbutton.com/properties/Hotel [R=301,L]
It does not work. Please advice.
Related
This question already has answers here:
301 Redirect to remove query string on homepage only
(1 answer)
Rewrite from any query string after root to root in .htaccess
(2 answers)
Closed 10 months ago.
I am using parameters on some subpages, but google index them in the search results for some reason in the homepage URL.
How can I please remove them in .htaccess only for homepage?
remove ?a=123 here:
example.com/?a=123 (result: example.com)
don't remove it here:
example.com/subpage/event.php?a=123
I found this, but I don't know how to apply it only for homepage:
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) $1?
Use this:
RewriteEngine On
RewriteCond %{QUERY_STRING} .
RewriteRule ^/?$ / [R=301,L,QSD]
%{QUERY_STRING} . means "query string contains at least one character"
^/?$ is "just the home page" -- ie the URL path only consists of an optional slash
[R=301] Redirects the request (to change the URL)
[L] is the last rewrite rule so that it doesn't conflict with later ones
[QSD] is "query string delete" so that rewrite doesn't try to append the query string to the redirect
This question already has answers here:
Redirect 301 with hash part (anchor) #
(8 answers)
Redirect URL with hash using .htaccess
(3 answers)
Hash(#) tag redirect in htaccess
(3 answers)
Closed 10 months ago.
Google has indexed one of my domain's wrong URL https://my-domain.com/#!. I want to permanently redirect this wrong URL to my domain root but the .htaccess file is not working. Here is my .htaccess file rule:
Redirect 301 https://my-domain.com/#! https://my-domain.com
I also tried:
Redirect 301 /#! https://my-domain.com
But non of them are working. Is there any mistake I am doing? Thanks
This question already has answers here:
Reference: mod_rewrite, URL rewriting and "pretty links" explained
(5 answers)
Closed 3 years ago.
I want to Redirect http://www.example.com/?page=1 to http://www.example.com/page/1 using Htaccess.
copy & paste this code in .htaccess file in your root directory
To keep the prefix and replace the last part with a query string
RewriteCond %{QUERY_STRING} !^id=
RewriteRule ^root/pages/(.+)$ /root/pages/?id=$1 [L]
The RewriteCond is needed to prevent a rewrite loop.
This question already has answers here:
Remove .php extension with .htaccess
(17 answers)
Closed 4 years ago.
My URLs look like this:
mywebsite.com/subpage-name.php
I want my new links to look like this:
mywebsite.com/subpage-name/
How can I redirect all my ".php" pages to "/" pages?
You have to add a RewriteRule in your .htaccess with a regex.
RewriteRule ^(.*)$ http://www.thenewdomain.com/$1 [R=permanent,L]
Make sure to add
RewriteEngine on
Before applying the redirect rule.
Happy Coding.
This question already has answers here:
Reference: mod_rewrite, URL rewriting and "pretty links" explained
(5 answers)
Closed 6 years ago.
I have a link like http://example.com/file.php?id=7gJKw2&d=78sfmnnsd8
I want to make this above url as
http://example.com/file/7gJKw2/78sfmnnsd8
Here is what I've tried
RewriteRule ^file/([a-zA-Z0-9_.-]+)$ file.php?id=$1
RewriteRule ^file/([a-zA-Z0-9_.-]+)/$ file.php?id=$1
How can i add the value of d & make it good looking?
You can bundle the entire a-zA-Z0-9_ pattern into a simple \w. As to the real question, just add the second part as follows:
RewriteRule ^file/([\w.-]+)/([\w.-]+)/?$ file.php?id=$1&d=$2 [L]
RewriteRule ^file/([\w.-]+)/?$ file.php?id=$1 [L]