Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-12-2012, 08:47 PM   PM User | #1
patrmich
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
patrmich is an unknown quantity at this point
How to redirect urls with a keyword to the site root

Hi,

I have re-built all my web site

The old site was built with frames.
Therefore numbers of urls are indexed by search engines in the following shape : http://www.mysite.com/index.html?target=page_xxx.html
So every of this url group has the keyword "target" inside

There is no frame in the new site
I am searching a way to write a redirection (in the htaccess file) from all the above urls to the site root : http://www.mysite.com

I thank you in advance for any help in this matter.

Best Regards,

Patrick
patrmich is offline   Reply With Quote
Old 11-13-2012, 07:20 AM   PM User | #2
poyzn
Regular Coder

 
poyzn's Avatar
 
Join Date: Nov 2010
Posts: 265
Thanks: 2
Thanked 61 Times in 61 Posts
poyzn is on a distinguished road
put into your .htaccess something like this:


PHP Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.+).html$ /index.html?target=$[L,R=301
and try to access mysite.com/page_xxx.html
__________________
Ushousebuilders.com
poyzn is offline   Reply With Quote
Old 11-13-2012, 09:04 AM   PM User | #3
patrmich
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
patrmich is an unknown quantity at this point
Hi,

Thank you poyzn for your reply.

I tried to add the 3 given lines to my htaccess file :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.html$ /index.html?target=$1 [L,R=301]


Then, I tried to open the here below url :
http://www.mysite.com/index.html?target=page_xxx.html


a- I got an error message in Google Chrome (in private navigation) :
"cette page présente une boucle de redirection" (this page has a redirect loop)
or
b- I got an error message in Firefox :
"La page n'est pas redirigée correctement" (The page is not properly redirected)

The displayed url in the browser bar was :
http://www.mysite.com/index.html?target=index

As a piece of information, I add that my new site root is :
http://www.mysite.com/index.php (or http://www.mysite.com)
and not
http://www.mysite.com/index.html

I thank you in advance if you can try to help me once again.

Kind Regards,

Patrick
patrmich is offline   Reply With Quote
Old 11-13-2012, 06:23 PM   PM User | #4
poyzn
Regular Coder

 
poyzn's Avatar
 
Join Date: Nov 2010
Posts: 265
Thanks: 2
Thanked 61 Times in 61 Posts
poyzn is on a distinguished road
I assume that you don't have index.html
What language do you use on your server?

If it is php I suggest you to use index.php instead of index.html and mod_rewrite config should be:
PHP Code:
RewriteCond %{REQUEST_FILENAME} !-// If there is no file with such name
RewriteCond %{REQUEST_FILENAME} !-// or directory
RewriteRule ^(.+).html$ /index.php?target=$[L,R=301// do rewrite with 301 redirect to remove old urls from search engines indexes 
__________________
Ushousebuilders.com

Last edited by poyzn; 11-13-2012 at 06:45 PM..
poyzn is offline   Reply With Quote
Reply

Bookmarks

Tags
htaccess, redirect

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:28 PM.


Advertisement
Log in to turn off these ads.