PDA

View Full Version : htaccess help


Warlord
12-23-2008, 03:47 AM
I have the following htaccess file


# This code handles redirecting to user profiles
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://DOMAIN.com/vb/member.php?username=$1 [R]

# This code handles fixing the log in problem wih vBadvanced
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^DOMAIN\.com
RewriteRule ^(.*)$ http://www.DOMAIN.com/$1 [R=permanent,L]


As the above states, I have two cases.

One to redirect domain.com/WHATEVER_USERNAME_IS_REQUESTED to domain.com/vb/member.php?username=WHATEVER_USERNAME_IS_REQUESTED

The other is to correct some cookie issues that I believe is unrelated to my problem but I thought I should include it in this post so you can see the entire file.

I want to exclude files and folders that actually exist on my server from being re-written URL's that direct you to a user profile. For instance, the folder blogs exists on my server and if I type in domain.com/blogs, I do not want to be redirected to http://DOMAIN.com/vb/member.php?username=blogs.

After reading up on htaccess files, I had thought that the first two RewriteCond lines in the file would solve this problem, but for some reason when I type in http://www.MYDOMAIN.com/blogs my browser gives me the following error.

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

As always, I'd appreciate any help or pointers anyone here would be willing to give me.

Best regards.

--------------- Added 1230089025 at 1230089025 ---------------

For anyone looking for the fix fir this problem... We were having some problems with this code, as it seemed to redirect actual directories that exist thinking that they were member user names.

The following code seems to work better. It also includes the fix for the log-in issues some users experience when site administrators use vBulletin and vBAdvanced.


Options +FollowSymLinks
RewriteEngine on
#
# Externally redirect to canonical hostname to fix vBadvanced login
# problems and to prevent duplicate content problems in search engines
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
# Internally rewrite all requests for URL-paths which do not resolve
# to existing files or directories to user profile script
RewriteCond $1 !^vb/member\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /vb/member.php?username=$1 [L]