Apache htaccess

sonic1234

Junior Member
Joined
Oct 19, 2009
Messages
131
Reaction score
25
Hello BHW,

i have a php website and it pulls data from mysql database.

i have urls like :
Code:
http://mydomain.com/video.php?name=video+name&id=1&tag=video-tag
i want it in this form:
Code:
http://mydomain.com/video-tag/video-name-id.html
What should i write in .htaccess to do this.

Thanks :)
 
No it doesnt work, (i have + in between url, how to make those + to -)

thanks anyways.
 
Ok i got the solution. :D
here it is:


Code:
RewriteRule ^(.*)/(.*)-id(.*).html video.php?id=$3
 
Ok i got the solution. :D
here it is:


Code:
RewriteRule ^(.*)/(.*)-id(.*).html video.php?id=$3

Good :) It wasn't hard to rewrite... (sorry about the above. haven't used apache/htaccess in a long time).

Here's what you should do though:

Code:
Options +FollowSymLinks
RewriteEngine on

RewriteRule ^(.*)/(.*)-(.*)-(.*)\.html$ video.php?name=$2+$3&id=$4

That way you'll be doing what you wanted:

Code:
http://mydomain.com/video-tag/video-name-id.html

e.g. http://mydomain.com/video-tag/myvideo-xpwizard-88134.html
 
Last edited:
Thanks Man, i am new to Apache :D

but why have you added a $ after .html here:

Code:
Options +FollowSymLinks 
RewriteEngine on  
RewriteRule ^(.*)/(.*)-(.*)-(.*)\.html$ video.php?name=$2+$3&id=$4
 
Thanks Man, i am new to Apache :D

but why have you added a $ after .html here:

Code:
Options +FollowSymLinks 
RewriteEngine on  
RewriteRule ^(.*)/(.*)-(.*)-(.*)\.html$ video.php?name=$2+$3&id=$4

^ = start of string
$ = end of string

It's just regex basics.
 
Back
Top