Radovan
08-10-2011, 12:10 AM
hello,
recently i have change the location of my web pages and because of google indexing i need to redirect the old ones to their new locations. Example: google is indexing this www.domain.com/pages/subpages/page.php but its new location is www.domain.com/pages/page.php. So i have added to my .htaccess simple redirect query and it's working. But I want also to rewrite the URL (remove "pages/" and php extension) so it will look like www.domain.com/page.
It should work like this: Someone clicks on my old indexed webpage (www.domain.com/pages/subpages/page.php), it will redirect him to this link -> www.domain.com/page, which should open a www.domain.com/pages/page.php , but leave in the user address bar the rewriten page (www.domain.com/page).
So i have made this .htaccess code
Redirect 301 /pages/subpages/page.php http://www.domain.com/page
RewriteEngine On
RewriteRule ^page/?$ /pages/page.php
It works almost correctly. When I open the page by www.domain.com/page it opens me a www.domain.com/pages/page.php and leave the rewriten page in address bar (that's what i have wanted to). But when I open it by the old link www.domain.com/pages/subpages/page.php , the redirect works but it leaves in the user's address bar the full page www.domain.com/pages/page.php, not the rewriten one (http://www.domain.com/page). It looks like the redirect and rewrite doesn't work correctly together. How to solve this?
mod_rewrite is allowed in my Apache. I tried to add line (I don't know what it really does)
Options +FollowSymLinks
but it gave me an 500 internal error.
I hope it's comprehensible.
recently i have change the location of my web pages and because of google indexing i need to redirect the old ones to their new locations. Example: google is indexing this www.domain.com/pages/subpages/page.php but its new location is www.domain.com/pages/page.php. So i have added to my .htaccess simple redirect query and it's working. But I want also to rewrite the URL (remove "pages/" and php extension) so it will look like www.domain.com/page.
It should work like this: Someone clicks on my old indexed webpage (www.domain.com/pages/subpages/page.php), it will redirect him to this link -> www.domain.com/page, which should open a www.domain.com/pages/page.php , but leave in the user address bar the rewriten page (www.domain.com/page).
So i have made this .htaccess code
Redirect 301 /pages/subpages/page.php http://www.domain.com/page
RewriteEngine On
RewriteRule ^page/?$ /pages/page.php
It works almost correctly. When I open the page by www.domain.com/page it opens me a www.domain.com/pages/page.php and leave the rewriten page in address bar (that's what i have wanted to). But when I open it by the old link www.domain.com/pages/subpages/page.php , the redirect works but it leaves in the user's address bar the full page www.domain.com/pages/page.php, not the rewriten one (http://www.domain.com/page). It looks like the redirect and rewrite doesn't work correctly together. How to solve this?
mod_rewrite is allowed in my Apache. I tried to add line (I don't know what it really does)
Options +FollowSymLinks
but it gave me an 500 internal error.
I hope it's comprehensible.