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

  • Home
  • SEARCH
  • 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 9064943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:22:53+00:00 2026-06-16T16:22:53+00:00

I am writing a mod rewrite rule to allow only one period between an

  • 0

I am writing a mod rewrite rule to allow only one period between an arbitrary length characters. The characters must begin with a letter, followed by 2-29 characters or numbers, and allow only one period (optional) somewhere in the middle (but never in the end).

Here is what I have so far:

RewriteCond    %{REQUEST_FILENAME}        !-f
RewriteCond    %{REQUEST_FILENAME}        !-d
RewriteRule    ^([a-z]([.a-z0-9]{2,29}))$    user.php?u=$1     [NC,QSA,L]

This rule is not working since it allows things like f.oo (valid), foo. (invalid), f.o.o (invalid), or even f.......

Is it possible to accomplish using just apache’s mod rewrite? Or does the check have to be done in PHP or somewhere else?

Similar questions: this one and this one.

Thank you.

  • 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-16T16:22:54+00:00Added an answer on June 16, 2026 at 4:22 pm

    I couldn’t do it in one rule, so I used two:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 ^.{3,30}$
    RewriteRule ^([a-z][a-z0-9]*(?:\.[a-z0-9]+)?)$ user.php?u=$1 [NC,QSA,L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help writing an htaccess redirect or rewrite rule (mod_rewrite.c) to handle the
can someone help me writing an RegEx for Apache Mod Rewrite? i wannt do
I'm writing some code for a very limited system where the mod operator is
Writing documentation in html requires some code examples. What to do with characters that
I'm writing a modding API for my game and I want to allow users
I am having a small trouble with mod rewrite. A friend of mine is
I'm writing a mod for a game(minecraft), for a friend. to do the specified
I am writing a Firefox add-on which uses context-menu and page-mod modules. This add-on
I'm trying to implement a new ReWrite rule on my local dev machine. I
i am currently writing a script mod for Grand Theft Auto IV using Scripthook

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.