1

I am trying to make the following redirection using .htaccess.

Redirect this:

http://www.example.com/[email protected]

To this:

http://www.example.com/index.php?something

So basically all I want is to remove @gmail.com from the query string whenever is presented while keeping everything else.

I tried the following:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)@gmail.com$
RewriteRule (.*) $1?%1%2? [R=permanent]

Unfortunately didn't work even after doing multiple tweaks. What is wrong?

3
  • Welcome to SO, could you please do provide details like uri [email protected] should be taken care by which file in backend? Thank you. Commented May 31, 2021 at 9:20
  • Sorry for not being clear enough. The processing page is index.php. So the URL is like this: website.com/[email protected] I need to remove @gmail.com whenever presented. So it should always be redirected to: website.com/index.php?something Commented May 31, 2021 at 9:54
  • This make sense, please do update your question with same details, thank you. Commented May 31, 2021 at 9:55

1 Answer 1

4

With your shown samples/attempts, please try following. Please make sure to clear your browser cache before testing your URLs. Please make sure that htacces and index.php files are on root folder at same level.

RewriteEngine ON
##Redirect rules to get index.php?something in browser here.
RewriteCond %{THE_REQUEST} \s/(index\.php)\?([^@]*)@.*\s [NC]
RewriteRule ^ /%1?%2 [R=301,L]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.