2

I need to redirect my old link(deleted) in my new link with a .htaccess file, for example,

From: http://www.example.com/page.php?value=2 (deleted)
To: http://www.example.com/detail.php?d=150

I tried with this but don't work. Becouse the file (page.php) does not exist, then the server give me 404 page not found.

My .htaccess

<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
RewriteEngine On
RewriteRule http://www.example.com/page.php?value=2 http://www.example.it/detail.php?d=150 [END,R=301]
order deny,allow

Can you help me?

1

2 Answers 2

7

RewriteRule directive does not receive the entire url, but the part of URI relative to the directive your htaccess file is inside. Also, it doesn't receive the query parameters, you'll have to access them with the RewriteCond directive. So, it should be:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^value=2$
RewriteRule ^page.php$ /detail.php?d=150 [R=301,L,QSD]
Sign up to request clarification or add additional context in comments.

Comments

3

Try :

RewriteEngine on
RewriteCond %{THE_REQUEST} /page\.php\?value=2$
RewriteRule ^ http://example.it?page.php?d=150 [L,R]

This would redirect

to

Reference : https://httpd.apache.org/docs/current/mod/mod_rewrite.html

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.