Please help me redirecting a page. I searched all the internet to fix this problem...but could not find anything. This is my last hope. Please help me: I'm trying to rewrite and then reditect the following url for example: www.mysite.com/index.php?id_produs=2760 into this html url: www.mysite.com/index.php-id_produs-2760.html ...and I added this code but didn't works: ---------------------------------------------------------------------- RewriteEngine on RewriteCond %{REQUEST_URI} ^index.php\?id_produs=([a-zA-Z0-9]*)$ RewriteRule index.php-id_produs-$1.html [R=301] ----------------------------------------------------------------------- I also tried this: ------------------------------------------------------------------------ RewriteEngine on RewriteRule -id_produs-(.*)\.html http://www.mysite.com/index.php?id_produs=$1 [R=301] ----------------------------------------------------------------------- The second example works fine regarding the rewriting...but it redirects the page to the php one...not to the html one that I need. Can you help me please? Thank you.
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^index\.php\-id_produs\-([0-9]+)\.html$ index.php?id_produs=$1 Code (markup): This should rewrite the request, however, it's not that simple, because all your html will still produce urls like index.php?produs_id=123 ...
Thank you KRAKJOE Your code works fine .....but how can I also redirect the old php url to the new html created after rewriting? Just want to avoid to be penalized for duplicate content. You know....the old php are still available using a direct request or in google cache. I added this but the browser redirect the html previously created after rewriting the php ...to the php again : ----------------------------------------------------------------------------------------- RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^index\.php\-id_produs\-([0-9]+)\.html$ index.php?id_produs=$1 [R=301] ------------------------------------------------------------------------------------------------- Once again, the above code does the following: 1. rewrite php into html 2. redirect html into php But I need this: 1. rewrite php into html 2. redirect old php from google cache to the html ones created after rewriting. Thank you.
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^index\.php\-id_produs\-([0-9]+)\.html$ index.php?id_produs=$1 RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^index\.php?id_produs=([0-9]+)$ index.php-id_produs-$1.html [R=301] Code (markup): If I understand correctly ...
When I direct request the php one ...it does not redirect me to the html one. It stands as it is....a php URL. The rewrite works fine...but I can not see any redirect to html. I just need to redirect: www.mysite.com/index.php?id_produs=2760 to www.mysite.com/index.php-id_produs-2760.html ..using rewriting in htaccess. Please help