Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have 2 pages for members profile pages and companies profile pages, for the members the url should be: site.com/users/USER_ID for the companies the url should be: site.com/COMPANY_ID

I have this in my .htaccess:

#Members Profile Page
RewriteRule ^users/(.*)$ modules/members/members_profile.php?id=$1
RewriteRule ^users/(.*)/$ modules/members/members_profile.php?id=$1

#Companies Profile Page
RewriteRule ^(.*)$ modules/companies/companies_profile.php?id=$1
RewriteRule ^(.*)/$ modules/companies/companies_profile.php?id=$1

But, these 2 rules have conflict which cause the users page also be leaded to companies_profile.php since the rule for companies also contain the users profile page in the address.

UPDATE: I've also used [L] flag, not working...:

#Members Profile Page
RewriteRule ^users/(.*)$ modules/members/members_profile.php?id=$1 [L]
RewriteRule ^users/(.*)/$ modules/members/members_profile.php?id=$1 [L]

#Companies Profile Page
RewriteRule ^(.*)$ modules/companies/companies_profile.php?id=$1
RewriteRule ^(.*)/$ modules/companies/companies_profile.php?id=$1

Still, it is loading companies_profile.php for URLs like /users/etc..

How I could solve this?

Thanks for any help

share|improve this question

1 Answer 1

This here works (/ at the begining) - according to the URL you posted, this will do what you want.

#Members Profile Page
RewriteRule ^/users/(.*)$ modules/members/members_profile.php?id=$1 [L]
RewriteRule ^/users/(.*)/$ modules/members/members_profile.php?id=$1 [L]

#Companies Profile Page
RewriteRule ^/(.*)$ modules/companies/companies_profile.php?id=$1
RewriteRule ^/(.*)/$ modules/companies/companies_profile.php?id=$1

What you wrote does not work because "^user/" never matches. Your URL is "/user/". ^ means begining of line. So what you have is not "beginning of line, user" but rather "begining of line, /, user".

share|improve this answer
    
Did that resolve your problem? –  ETL Feb 20 '13 at 19:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.