views:

75

answers:

3

Hi,

http://mysite.com/songs/company-name/song-name

i want to redirect it to

http://mysite.com/songs/index.php?name=company-name&song=song-name

i read some articles about that mod_rewrite but actually i couldnt understand exactyly, i appreciate if you can help me.

thanks

EDIT: mod rewrite is enabled

A: 

Check if your apache installation has mod_rewrite enabled.

In its simplest form, the rule to accomplish what you want to do would be:

In your .htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteRule ^/?$ http://mysite.com [R=301,L]

RewriteRule songs/(.*)/(.*)$ songs/index.php?name=$1&song=$2

But give it a read to the apache documentation http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html as well as verify your configuration, and here you'd find some useful stuff as well http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#redirects

Hope that helps.

falomir
thanks but this caused "This webpage has a redirect loop." when i go to "mysite.com"
Ahmet vardar
Try removing this line RewriteRule ^/?$ http://mysite.com [R=301,L]
falomir
A: 
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^([\d\w]+)/([\d\w]+)$ test.php?name=$1&song=$2 [L]
Adrian
i cant make it work too :(
Ahmet vardar
A: 
RewriteEngine On
RewriteRule   ^/songs/([\d\w\-]+)/([\d\w\-]+)$   test.php?name=$1&song=$2 [L]

Sometimes it helps to have logging turned on:

RewriteLogLevel 4
RewriteLog /home/www/mysite.com/log/rewrite.log
kguest