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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:02:43+00:00 2026-06-03T06:02:43+00:00

So I have a couple of mod_rewrite rules to make URL’s prettier. By this

  • 0

So I have a couple of mod_rewrite rules to make URL’s prettier.

By this I mean I wish to change a url that is entered as such:

http://test.domain.com/cheese/wine/

to a background association towards the test.php as such:

http://test.domain.com/test.php?client=test&page=cheese/wine

PS: The client variable above is actually the [test].domain.com.

According to the rewrite log all the RewriteRule’s seem to work fine but all I get is a 400 error.


vHost file:

<VirtualHost *:80>
  ServerName *.domain.com
  DocumentRoot /var/www/dir/

  ...

  RewriteEngine on

  # drop www. from subdomains
  RewriteCond %{HTTP_HOST} ^www\.(.*)\.domain.com$
  RewriteRule ^/?(.*)$ http://%1.domain.com/$1 [R=301]

  # rewrite x.domain.com/abc to abc?client=x
  RewriteCond %{HTTP_HOST} ^([^.]+)\.domain.com$
  RewriteRule ^/?(.*)$ $1?client=%1 [QSA]

  RewriteRule ^/?(.*)$ test.php?page=$1 [QSA,L]

  ...
</VirtualHost>

Does anyone have any ideas?


Edit: The request hostname (*.domain.com) needs to stay intact because (www.)domain.com is treated in a different manner.

  • 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-03T06:02:44+00:00Added an answer on June 3, 2026 at 6:02 am

    Your code generates an infinite loop.

    <VirtualHost *:80>
      ServerName *.domain.com
      DocumentRoot /var/www/dir/
    
      ...
    
      RewriteEngine on
    
      # drop www. from subdomains
      # also drop www. from main domain
      RewriteCond %{HTTP_HOST} ^www\.(.*\.)?domain.com$
      RewriteRule ^/?(.*)$ http://%1domain.com/$1 [R=301]
    
      # rewrite x.domain.com/abc to abc?client=x
      RewriteCond %{REQUEST_URI} !^test\.php
      RewriteCond %{HTTP_HOST} ^([^.]+)\.domain.com$
      RewriteRule ^/?(.*)$ test.php?page=$1&client=%1 [QSA,L]
    
      ...
    </VirtualHost>
    

    I also modified the code so www.domain.com/ redirect to domain.com/

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

Sidebar

Related Questions

I have couple of dozen pieces of data that I need to save and
I have couple questions regarding some C++ rules. Why am I able to call
I have couple resource DLLs that I currently load when application starts using following
I have couple of questions about AS3 variables handling by AVM/compiler/scope .1. This code
We have couple different web-apps that share the same db link. The hibernate layer
ok I have couple of .NET classes that I want to use in VBA.
I have played a while with ZeroMQ and have couple questions/problems that I came
I have couple of statements, the pseudo code would look something like this: insert
I have couple of hyperlinks on my website. What I want is to remove
I have couple of formulas and data coming from database. I want to refresh

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.