remove string from URL

Using mod_rewrite to handle various content issues

remove string from URL

Postby VChris » Thu May 21, 2009 6:48 am

What code should I write into .htaccess if I would like to make a 301 redirect from domain.hu/hu/something to domain.hu/something?
VChris
 
Posts: 4
Joined: Fri Mar 13, 2009 12:54 pm

Postby richardk » Thu May 21, 2009 7:09 am

Try (mod_dir)
Code: Select all
Redirect 301 /hu/ http://www.example.hu/

or (mod_rewrite)
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^hu(/(.*))?$ /$2 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby VChris » Thu May 21, 2009 8:53 am

Thanks for your reply.

I tried these codes.

The first: It works, but not as I would expect.

First code makes:

domain.hu/hu/something => domain.hu/something?q=hu/something

It is not good for me, it' no SEO friendly.
Or is there a possibility to cut off the end of the URL: ?q=hu/something after 301 redirecting?

The second code (Rewrite) doesn't work at all. :(

In that code I don't see RewriteCond. Should it be the reason?

Or any solution to solve my problem, I need it much.
VChris
 
Posts: 4
Joined: Fri Mar 13, 2009 12:54 pm

Postby richardk » Thu May 21, 2009 4:11 pm

Post the whole mod_rewrite.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Content

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron