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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:45:28+00:00 2026-05-24T17:45:28+00:00

I’ve always been bad at apache and used very simple solutions. Right now I

  • 0

I’ve always been bad at apache and used very simple solutions. Right now I have built a cms software.. but the .htaccess is starting to be a huge downsize.

I will first explain, how my friendly-urls work and look like. My language-switch is url based and always contains two characters. And it looks like this: stackoverflow.com/en/ this makes the switching really easy and since its url based.. it works well in the SEO terms. Also, if no language-id is set, then the default language will be used (stackoverflow.com/).
There are no page-ids in numbers. I have unique page-ids in text: stackoverflow.com/services.html and for SEO and folder-directories-anti-conflict purposes .html at the end..
For subpages I have “$current_page” and “$parent_page” style variables: stackoverflow.com/services/translating.html Services being the parent and translating being the current page.
Some sample code too (I nerfed it alot, so you don’t think its incomplete):

RewriteRule ^(et|en|fi)\/(.+)\/(.+)\.html  index.php?language=$1&pagelink=$3&parentlink=$2 [L,NC,QSA]

RewriteRule ^(.+)\/(.+)\.html  index.php?language=0&pagelink=$2&parentlink=$1 [L,NC,QSA]
RewriteRule ^(.+)\.html  index.php?language=0&pagelink=$1&parentlink=0 [L,NC,QSA]

How can I make the language-switch part more dynamic?
This method ..^(et|en|fi)\/.. means, that when I set up the cms, I must manually set the languages list. Best bet would be to set it somehow from the cms settings. Because, this way there are no conflicts related to folders. Is it possible global apace variable via php and then display it the .htaccess file? Something like this: ..^(LANGUAGELISTS)\/..? If this isn’t possible, then next best thing would be to match 2 characters in that location and pass it as $_GET['language'].

How can I have unlimited parents dynamically?
Meaning, that the “$parent_page” is not set statically and I have unlimited children, similar to this: stackoverflow.com/services/translating/english/somesubpage.html. If that is possible, then also, how will it be used in the php, with an array?

Bounty edit
First part of the question is basically solved, unless somebody comes up with some php -> apache-array -> .htaccess way.
However, the second part of the question is still not solved. Since this is been the problem with all my projects and could possibly help somebody else in the future, I decided to add bounty to this question.

  • 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-24T17:45:29+00:00Added an answer on May 24, 2026 at 5:45 pm

    To answer your first question:
    You could use RewriteRule ^([a-zA-Z]{2})([/]?)(.*)$ path/file.php?language=$1
    This limits the first string to two characters and passes it on to $_GET['language']

    Edit: adding RewriteCond %{REQUEST_FILENAME} !-f
    and RewriteCond %{REQUEST_FILENAME} !-d will prevent conflicts with existing directories / files

    Second question is much more difficult..

    Update:

    What Shad and toopay say is a good start in my opinion.
    Using explode() to seperate levels and comparing it to the slug is quite simple.
    But it’s getting complicated once you want to add flexibility to the script.

    function get_URL_items() {
    $get_URL_items_url = $_SERVER['REQUEST_URI'];
    $get_URL_items_vars = explode("/",$get_URL_items_url);
    for ($get_URL_items_i = 0; $get_URL_items_i < count($get_URL_items_vars) ; $get_URL_items_i++) {
        if(strlen(trim($get_URL_items_vars[$get_URL_items_i])) == 0) {
            unset($get_URL_items_vars[$get_URL_items_i]);
        }
    }
    return $get_URL_items_vars;
    

    Let’s say you you’ve got a website with a sub-section called “Festival” and a database filled with info for 100+ artist and you want your URLs to look like website.com/festival/<artistgenre>/<artistname>/.
    You don’t want to create 100+ pages in your CMS so <artistgenre> and <artistname> are some kind of wildcards.

    I found it hard to achieve this without a lot of if/else statements like:

    $item = get_URL_items();    
    if(is_user($item[2]) && is_genre($item[1]) && is_festival($item[0])) {
      // do mysql stuff here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.