A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearReWriteRule Apache, php - page 1
User InfoPosts
ReWriteRule Apache, php#1
I want to be able to redirect the user when they type in http://example.com/user/user-name to http://example.com/user/user-name, which displays user details

This is what I am using but it gives me errors

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^.*$ /user/ [R]

The error which firefox gives is

Redirect Loop

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.

Have you disabled or blocked cookies required by this site?
NOTE: If accepting the site(s cookies does not resolve the problem, it is likely a server configuration issue and not your computer.


posted date: 2009-04-09 00:36:00

Re: ReWriteRule Apache, php#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-09 00:36:01

Re: ReWriteRule Apache, php#3
are those two urls not the same?Edit: when i replied, the question only stated the need, not the error

posted date: 2009-04-09 00:39:00

Re: ReWriteRule Apache, php#4
You indeed have a redirect loop. You are trying to go from domain.com/user/user-name to domain.com/user/user-name (the SAME URL). What happens is:User accesses domain.com/user/user-name.User is redirected to domain.com/user/user-name (the same location).User is redirected again to domain.com/user/user-name (the same location).User is redirected again to domain.com/user/user-name (the same location).Repeat ad nauseum...Perhaps you meant to redirect domain.com/user/user-name to domain.com/users.php?u=user or something?

posted date: 2009-04-09 00:43:00

Re: ReWriteRule Apache, php#5
You(re redirecting everything to /user/ including itself.Edit:Every request runs through the same set of rewrites, and since your regex of ^.*$ matches you(ll redirect /user/ to /user/ again. The browser is just helping you out by stopping the loop after a few attempts on the same URL.If you(re looking to redirect /a/foo to /b/foo, you need something like:RewriteRule ^/a/(.*)$ /b/$1 [R]..but you need to have the source and destination not overlap as in your initial example, or you(ll get an infinite redirect loop.

posted date: 2009-04-09 01:03:00

Re: ReWriteRule Apache, php#6
guys can i have a solution rather than telling me i am wrong :D

posted date: 2009-04-09 01:12:00

Re: ReWriteRule Apache, php#7
As the others already said, the RewriteRule matches any URI path (including /user/) and thus lead into an infinite loop.To avoid this you have to exclude this URI path:# eitherRewriteRule !^/user/$ /user/ [R]# orRewriteCond %{REQUEST_URI} !^/user/$RewriteRule ^ /user/ [R]These rules redirect every URI path that is not matched by ^/user/$ to /user/. If you want to use this rule in a .htaccess file, you have to remove the leading slash in the pattern of the RewriteRule directive (so just ^user/$).

posted date: 2009-04-09 01:51:00

Re: ReWriteRule Apache, php#8
if a any user wants to view another user data they just have to type in domain.com/user/user-name/ the rest the script should do

posted date: 2009-04-09 01:53:00

select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.