Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 927269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:49:21+00:00 2026-05-15T19:49:21+00:00

is possible to exclude a url being parsed by mod rewrite? my .htaccess has

  • 0

is possible to exclude a url being parsed by mod rewrite?
my .htaccess has rewrite rules like

RewriteRule ^contact contact_us.php

and a couple more static pages.

currently my site don’t have troubles cause uses http://domain.com/user.php?user=username
but now i need rewrite to:

http://domain.com/username

I’ve tried with:

RewriteRule ^(.*)$ user.php?user=$1 [L]

but all my site stops working…

is possible to avoid parse my static pages like contact/feed/etc being treated like usernames?

edit to match david req:

this is my actual .htaccess file:

RewriteEngine On
Options +Followsymlinks

RewriteRule ^contact contact_us.php [L]
RewriteRule ^terms terms_of_use.php [L]
RewriteRule ^register register.php [L]
RewriteRule ^login login.php [L]
RewriteRule ^logout logout.php [L]
RewriteRule ^posts/(.*)/(.*) viewupdates.php?username=$1&page=$2 
RewriteRule ^post(.*)/([0-9]*)$ viewupdate.php?title=$1&id=$2 
RewriteRule ^(.*)$ profile.php?username=$1 [L] 

also i’ve enabled modrewrite log my first file:http://pastie.org/1044881

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:49:22+00:00Added an answer on May 15, 2026 at 7:49 pm

    Put the rewrite rules for the static pages first, and add the [L] flag to them:

    RewriteRule ^contact contact_us.php [L]
    ...
    

    then after those, use your rewrite rule for the username:

    RewriteRule ^(.*)$ user.php?user=$1 [L]
    

    (hopefully nobody has a username of contact).

    EDIT: Based on the log output you posted (which I’m assuming corresponds to an unsuccessful attempt to access the contact page… right?), try changing the contact rewrite rule to either

    RewriteRule ^contact$ contact_us.php [L]
    

    or

    RewriteRule ^contact contact_us.php [L,NS]
    

    That is, either add $ to make the pattern match only the literal URL contact, or add the NS flag to keep it from applying to subrequests. According to the log output, what seems to have happened is that Apache rewrites contact to contact_us.php and then does an internal subrequest for that new URL. So far so good. The weird thing is that the ^contact pattern again matches contact_us.php, “transforming” it to contact_us.php, i.e. the same thing, which Apache interprets as a signal that it should ignore the rule entirely. Now, I would think Apache would have the sense to ignore the rule only on the subrequest, but I’m not sure if it’s ignoring the entire rewriting process and leaving the original URL, /contact, as is. If that’s the case, making one of the changes I suggested should fix it.

    EDIT 2: your rewrite log excerpt reminded me of something: I’d suggest making the rewrite rule

    RewriteRule ^([^/]+)$ user.php?user=$1 [L]
    

    since slashes shouldn’t be occurring in any usernames. (Right?) Or you could do

    RewriteRule ^(\w+)$ user.php?user=$1 [L]
    

    if usernames can only include word characters (letters, numbers, and underscore). Basically, make a regular expression that matches only any sequence of characters that could be a valid username, but doesn’t match URLs of images or CSS/JS files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know if it's possible with Ant4Eclipse to exclude some folders,
Possible Duplicate: How to successfully rewrite old mysql-php code with deprecated mysql_* functions? I
Is it possible to exclude certain fields from being included in the json string?
Is it possible to exclude certain Facebook IDs in the apprequests dialog like the
Is it possible to exclude a folder in a web project from being published?
Is it possible to exclude certain subviews in a UITableViewCell from being highlighted or
Is it possible to exclude specific files or folders from Build Deployment Package function
Is it possible to exclude specific files (*.ai, *.psd) when pushing to certain repositories
Possible Duplicate: SQL exclude a column using SELECT * [except columnA] FROM tableA? I
Possible Duplicate: What is the fastest XML parser in PHP? I still need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.