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 8347391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:21:10+00:00 2026-06-09T07:21:10+00:00

I have the following code in my .htaccess. RewriteEngine On RewriteRule ^/(\w+)/?$ /?user=$1 I’m

  • 0

I have the following code in my .htaccess.

RewriteEngine On
RewriteRule ^/(\w+)/?$ /?user=$1

I’m trying to rewrite
http://domain.com/?user=username into http://domain.com/username. Unfortunately this code doesn’t rewrite anything. Please help

Note:
I checked phpinfo() and mod_rewrite is loaded.

Update

I need to get username from url like http://facebook.com/username. But this code rewrites every folder in root folder, so my /css folder become http://domain.com/css/?u=common. How to allow this code works only for http://domain.com/index.php

  • 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-06-09T07:21:11+00:00Added an answer on June 9, 2026 at 7:21 am

    The mistake you are doing is the use of / in the beginning of the line ^/(\w+)/?$

    rewrite rules strips off the / from the beginning of the pattern to be matched in .htaccess and directory context.

    Try doing this:

    RewriteEngine On
    RewriteRule ^(\w+)/?$ /?user=$1
    

    From RewriteRule Directive docs :

    What is matched?

    In VirtualHost context, The Pattern will initially be matched against the part of the URL after the hostname and port, and before the query string (e.g. “/app1/index.html”).

    In Directory and htaccess context, the Pattern will initially be matched against the filesystem path, after removing the prefix that lead the server to the current RewriteRule (e.g. “app1/index.html” or “index.html” depending on where the directives are defined).

    If you wish to match against the hostname, port, or query string, use a RewriteCond with the %{HTTP_HOST}, %{SERVER_PORT}, or %{QUERY_STRING} variables respectively.


    Edit: Answer updated as per OP’s request:
    Add this :

    RewriteEngine On
    
    #do nothig if URL is trying to access the folder CSS.
    RewriteRule *css/* - [L]
    
    #checks where the URL is a valid file/folder.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(\w+)/?$ /?user=$1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in my .htaccess the following code: RewriteEngine On RewriteRule ^/?([^/\.]+)/?$ $1.php [L]
Looking to put the following into my htaccess file: User visits http://mysite.com/test/test/123 User is
I have the following code in ://localhost/.htaccess... AddType application/x-httpd-php5 .css .js RewriteEngine on RewriteRule
I have the following code in my htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} !^www.example.com$
I have the following code in my .htaccess: RewriteEngine On RewriteBase / RewriteRule ^index\.php$
I have the following code: RewriteEngine On RewriteRule ^user/([0-9]+)/([0-9]+)/?$ template.php?user_id=$1&slide=$2 [NC,L,QSA] So when I
i have used the following code in .htaccess Options +FollowSymlinks RewriteEngine On RewriteBase /
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have follwing code in .htaccess file Options +FollowSymLinks RewriteEngine on RewriteRule tricks tricks.php?show=all
I have the following code in my .htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME}

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.