Help with my htaccess

New to mod_rewrite? This is a good place to start.

Help with my htaccess

Postby Dyshka » Sun Aug 23, 2009 10:32 am

I have a music site (hiturialese.net) . The url of the songs are like my example

http://mysite.com/category/artist-song.html

and in htaccess is writed


Code: Select all
RewriteEngine On
RewriteBase /
RewriteRule ^categoryname1/([a-zA-Z0-9_$\-]+)\.html$ song.php
RewriteRule ^categoryname2/([a-zA-Z0-9_$\-]+)\.html$ song.php
RewriteRule ^categoryname3/([a-zA-Z0-9_$\-]+)\.html$ song.php
etc.



How i can edit htacces to give me the link off all songs like this

http://arist-song.mysite.com .

Can you help me and edit my htaccess
Last edited by Dyshka on Mon Aug 24, 2009 8:43 am, edited 1 time in total.
Dyshka
 
Posts: 5
Joined: Sun Aug 23, 2009 10:27 am

Postby Dyshka » Mon Aug 24, 2009 1:32 am

Nobody :(
Dyshka
 
Posts: 5
Joined: Sun Aug 23, 2009 10:27 am

Postby spiderwebs » Mon Aug 24, 2009 7:45 am

RewriteCond %{HTTP_HOST} ^artist\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/artist.html/$1 [P,L]

hope it will work
spiderwebs
 
Posts: 3
Joined: Mon Aug 24, 2009 7:05 am

Postby Dyshka » Mon Aug 24, 2009 8:44 am

spiderwebs wrote:RewriteCond %{HTTP_HOST} ^artist\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/artist.html/$1 [P,L]

hope it will work


no . artist.html in not a file on my host . is generated from song.php file.

i think will not work .
Dyshka
 
Posts: 5
Joined: Sun Aug 23, 2009 10:27 am

Postby richardk » Mon Aug 24, 2009 2:15 pm

FAQ: Virtual sub domains.

The FAQ wrote:Note: this will only work if you have DNS for the sub domains (probably Wildcard DNS) and the server configured to send the requests to the same document root.


Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ /song.php [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Dyshka » Mon Aug 24, 2009 8:37 pm

Now i don't get error 500 , i get a white page .

http://muzica69.com , click on 1 song name from caterory ALBUME . to see my problem .
Dyshka
 
Posts: 5
Joined: Sun Aug 23, 2009 10:27 am

Postby richardk » Sat Aug 29, 2009 2:05 pm

What happens if you remove the mod_rewrite and go to the sub domain?

What happens if you use
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ http://www.example.com/song.php [R,L]

?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Dyshka » Mon Aug 31, 2009 1:45 am

richardk wrote:What happens if you remove the mod_rewrite and go to the sub domain?

What happens if you use
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ http://www.example.com/song.php [R,L]

?



When i put this on htaccess and when i click on a song i'm redirected to

http://www.muzica69.com/song.php

and i've got this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Dyshka
 
Posts: 5
Joined: Sun Aug 23, 2009 10:27 am

Postby richardk » Mon Aug 31, 2009 8:11 am

Which .htaccess file are you putting it in? muzica69.com/.htaccess?

and i've got this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

You also get that error when you visit /song.php, it is a problem with your PHP script (probably that no "artist-song" has been passed to it).

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ song.php [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 27 guests

cron