in my website I have some pages structured in this way:
http://www.mysite.com/x/y.php?query=z
I wrote a rule in my .htaccess file that is rewriting the pages in this way:
Now, since I am getting some SEO problems with these urls I would like my .htaccess file to 301 redirect both urls (www.mysite.com/x/y.php?query=z and http://www.mysite.com/x-y/z) to something like this:
http://www.mysite.com/x-y/z.html
I can I do this? I am posting you my .htaccess rule:
AuthType Basic
RewriteEngine on
RewriteRule ([^/]+)-([^/]+)/([^/]+) $1/$2.php?titolo=$3 [L]
Thanks in advance!
Greetings from Italy
EDIT
Hi, as I wrote in my first post I need to 301 redirect some pages in my website. I have for example some pages like this:
http://www.mysite.com/dir/subdir/page.php?titolo=foo
which are now written like this (I am using the code I posted before):
http://www.mysite.com/dir/subdir-page/foo
Now I want to 301 redirect both http://www.mysite.com/dir/subdir/page.php?titolo=foo and http://www.mysite.com/dir/subdir-page/foo to this:
http://www.mysite.com/dir/subdir-page/foo.html
I put my htaccess in the “dir” folder. However the code you gave me did not work, I am sorry… since I am new to the htaccess I would appreciate very well your help.
Thanks in advance and best regards from Italy
Use this code: