PDA

View Full Version : mod_rewrite


DjCanaydia
12-24-2008, 10:45 PM
Hello, i have been having coding trouble with a .htaccess code, i am not sure what type of code it is cuz im not great at this stuff but i figured it out once before but i switched hosts and now its gone wrong. the mod_rewrite uses the code from htaccess to view ppl profiles such as website.com/username
whenever i go to upload the current code the script gives me to put in the .htaccess i get a redirect loop. Here is the code.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-F
RewriteRule ^([-_!*$@~:.a-zA-Z0-9]+)$ http://hardbassbeats.com/profile.php?username=$1

Here is the website www.hardbassbeats.com/index.php , if u click on a users profile u can see what i mean.

(I do not have the .htaccess file inside the web host right now. if i do the whole site no matter what page u visit u just get a redirect loop)

If this is the wrong section for this i am sorry but i could not find a better category. All help is appreciated. Thanks in advance.

-Dj Canaydia.

schleppel
12-25-2008, 01:25 AM
Your rule matches the URL you are redirecting to. You want !-f (not an existing file) not !-F (not an existing file via a subrequest).

Try
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /profile.php?username=$1 [QSA,L]

DjCanaydia
12-25-2008, 03:49 AM
omg thank you so much, the site has had that error for atleast a month and its stopped traffic by alot, this fixed it and u have no idea how appreciated i am :)
Thanks you again schleppel, alot :D

See you guys around and Merry Christmas :thumbsup:

~Dj Canaydia