1

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

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks but this caused "This webpage has a redirect loop." when i go to "mysite.com"
0
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^([\d\w]+)/([\d\w]+)$ test.php?name=$1&song=$2 [L]

Comments

0
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.