Forum Moderators: phranque
# This code handles redirecting to user profiles
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ [DOMAIN.com...] [R]# This code handles fixing the log in problem wih vBadvanced
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^DOMAIN\.com
RewriteRule ^(.*)$ [DOMAIN.com...] [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...] I do not want to be redirected to [DOMAIN.com ].
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 [DOMAIN.com ] 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.
I'd appreciate any help or pointers anyone here would be willing to give me.
Best regards.
Note also that the first rule causes a 302 redirect, not a 301. 302 redirects can cause great problems with search engine listings and rankings of your site's URLs, and you should use R=301 or R=Permanent in your redirects unless you specifically want to mark the redirect as temporary.
In fact, there is no reason to redirect at all, and doing so 'exposes' your "member.php" script URL and query strings in the browser address bar. You'll likely be much happier if you internally rewrite those URLs instead of redirecting them:
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]
Jim
[edited by: jdMorgan at 4:36 pm (utc) on Dec. 23, 2008]
This problem is due to the fact that is is the client --browser or robot-- which resolves relative links. It does so based on the directory-level that is "sees" in its address bar. With your new URLs, the client is looking for relatively-linked images in or below the "/WHATEVER_USERNAME_IS_REQUESTED" directory level.
Use server-relative or canonical URLs in your links, as in <img src="/images/logo.gif"> or <img src="http://www.example.com/images/logo.gif"> to avoid this problem.
Jim
This is not an Apache-specific question and I don't know your site or your code, so those are just my best guesses.
Jim