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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:30:38+00:00 2026-05-23T20:30:38+00:00

For my site I have a directory called /test/ . I want to rewrite

  • 0

For my site I have a directory called /test/. I want to rewrite www.example.com/nl/test and www.example.com/nl/test/ to a certain page (test.php).

Some global conditions (for all the rules)

RewriteRule ^(nl|en)$ http://www.example.com/$1/ [NC,R]
RewriteBase /

RewriteRule ^(nl|en)$ $1/ [NC,R]

RewriteCond $1 !^(en|nl)$
RewriteRule ^([a-z]{2})/(.*)$ en/$2 [L,R=302]

RewriteRule ^(nl|en)/(.*)$ $2?language=$1&%{QUERY_STRING} [L]

RewriteRule ^sale$ sale.php
RewriteRule ^valentine$ valentine.php

Some conditions for the rewrite + folder

RewriteRule ^test/$ test.php

The redirect of www.example.com/nl/test/ is correct. The language parameter is also correctly rewritten.

For the second redirect (the version without the trailing slash) I can’t get this working.

RewriteRule ^test$ test.php

Now my URL is rewritten as www.example.com/test/?language=nl

Can someone give me a tip or hint to fix this? I can’t change the name of the directory since there are several external URLs linking to this directory.

  • 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-23T20:30:40+00:00Added an answer on May 23, 2026 at 8:30 pm

    This rule will do the whole job (instead of 4 lines you have there): it will rewrite both /nl/test and /nl/test/ to /test.php?language=nl.

    RewriteRule ^(en|nl)/test/?$ /test.php?language=$1 [NC,QSA,L]
    

    NOTES:

    The [QSA] flag will preserve any existing query string (therefore, there is no need for &%{QUERY_STRING}).


    Full .htaccess:

    Options +FollowSymLinks -MultiViews
    DirectorySlash Off
    
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^(nl|en)$ http://www.example.com/$1/ [NC,R=301,L]
    
    RewriteCond $1 !^(en|nl)$
    RewriteRule ^([a-z]{2})/(.*)$ /en/$2 [R=302,L]
    
    RewriteRule ^(nl|en)/(.*)$ /$2?language=$1 [NC,QSA,L]
    
    RewriteRule ^sale/?$ sale.php [QSA,L]
    RewriteRule ^valentine/?$ valentine.php [QSA,L]
    RewriteRule ^test/?$ test.php [QSA,L]
    

    NOTES:

    There is no need for RewriteRule ^(nl|en)$ $1/ [NC,R] as you already have RewriteRule ^(nl|en)$ http://www.example.com/$1/ [NC,R=301,L]. It does the same job.

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

Sidebar

Related Questions

I have a site that sits in a directory on a domain: http://www.example.com/site/ I
I have a library called example that I'm installing into my global site-packages directory.
I have my php in /srv/www/site directory, which resolves to www.domain.com/site . How can
I have a photographic portfolio site.when image on single.php page is clicked the_content() function
I have a directory called private. You can access the index.php file by using
For my site I have a RewriteRule that points the URL http://www.mysite.com/work to a
Okay so I have a wordpress site. for example wordpress.com On it I have
I have a css file that links to images. .test{ background: url(http://site.com/dynamic/test.jpg) no-repeat; }
I have a script called 'sess-start.php' which lies in an /include directory within my
I have a site that has a /sites/default/files/ directory where user content is typically

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.