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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:33:13+00:00 2026-06-16T02:33:13+00:00

Hello I’m making a website and I have issues with htaccess clean url redirects

  • 0

Hello I’m making a website and I have issues with htaccess clean url redirects when a user adds amps or slashes as a title for the article he is submiting.I decided thath I would like to allow only specific characters like alpanumeric, -, _, @,[,]. no quotes or double quotes etc etc…

I cant seem to make the regexp work I have not great esperience with regex and instead of using string replaces I thought I should ask.

Also any other proposals regarding this matter will be greatly appreciated

In my htaccess I have the following setup:

RewriteRule ^([^/]*)(.*)$ /index.php?page=$1&request=$2

and in my index I have:

include 'db.php';
include 'generic.php';

$pages = array('','main','events','news','rss','search','add-event');

if(isset($_GET['page']) && in_array($_GET['page'], $pages))
{
    $event_category = null;
    $event_title = null;
    $search_string = null;
    $rss_category = null;
    $events_date = null;
    $search_page = null;

    validate_evented_page(trim(urldecode($_GET['page'])));
}
else
{
    evented_error_page(404);
}

function evented_error_page($err)
{
    include('errorpages/error.php');
}

function validate_evented_page($p)
{
    $page = strtolower($p);

    global $event_category;
    global $event_title;
    global $search_string;
    global $rss_category;
    global $events_date;
    global $search_page;

    if($page == 'main' || strlen($p) == 0)
    {   
        include 'main.php';
    }
    else if($page == 'events')
    {
        $params = explode_url($_GET['request']);

        if(count($params) == 0)
        {
            $events_date = "'';";
            include 'allevents.php';
        }
        else if(count($params) == 1)
        {   

            if(check_date($params[0]))
            {
                $date_split = explode('-',$params[0]);
                $events_date = "'".date("m/d/Y" , mktime(0, 0, 0, date('m'), $date_split[1], date('Y')))."';";
            }
            else
            {
                $events_date = "'';";
            }

            include 'allevents.php';
        }
        else if(count($params) == 2)
        {
            $event_category = trim(urldecode($params[0]));
            $event_title = trim(urldecode($params[1]));

            include 'event.php';
        }
        else
        {
            evented_error_page(404);
        }

    }
}

the following url:

/events/Drum+%26+Bass/Innersense+presents+ETHOS_v04-0

gives $_GET[‘request’] = /Drum

when it should have been Drum & Bass (in the database I have stored this category as “Drum & Bass”).

  • 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-16T02:33:14+00:00Added an answer on June 16, 2026 at 2:33 am

    You need to tell mod_rewrite to encode the & that gets grouped in the backreferene using the B flag:

    RewriteRule ^([^/]*)(.*)$ /index.php?page=$1&request=$2 [B,L]
    

    The URI gets decoded when it gets sent through the rewrite engine. So the %26 gets decoded to &, the B flag ensures it gets re-encoded as the backreference.

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

Sidebar

Related Questions

Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello I have following column in SSRS Report. Column Name(Title) Mehta, Natasha(18)----its Title+(count) value
Hello guys i have an website online wich access the database. The database access
Hello guys, I have an error I cannot solve, on a ASP.NET website. One
Let's say I'm outputting a post title and in our database, it's Hello Y’all
hello all i am working on a project in which i have a webpage
Hello i'm doing a application in php, and i have a list of items
hello for my app I need to save a record that the user type,
Hello I want to get Accurate location so that i have used following link
Hello guys i have been using JavaFx scene builder to build a gui that

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.