mod_rewrite URL's with "anything" in the url

Posted on 2012-09-11
Last Modified: 2012-09-16
I'm trying to use mod_rewrite to redirect a php site.

In my .htaccess file I have
RewriteRule ^([a-z0-9]+)/(.*+)/?$     index.php?action=$1&data=$2  [NC] 
RewriteRule ^([a-z0-9]+)/?$     index.php?action=$1  [NC] 

Open in new window

But I'd like to make it handle any characters (legal - not / obviously) instead of only a subset

I have a specific problem - the link is "" but the $_GET["data"] only get's "journalistik"

Any help will be appreciated :)
Question by:internetservice_dk
    LVL 29

    Accepted Solution

    1 - Change [a-z0-9] by including additional characters you want; be ready though to discover that some will never make it thru; try [+0-9a-zA-Z%,_]

    2 - You say that your RewriteRule ^([a-z0-9]+)/(.*+)/?$     index.php?action=$1&data=$2 creates a problem when data should be journalistik+%26+Formidling
    but %26 is the ansi code for &....
    Look for solutions at
    My preferred solution there would be the solution 1
     Use the B rewrite flag:

    Author Closing Comment

    Thanks - works like a charm
    LVL 29

    Expert Comment

    B-) Glad to help. Thx for the grade and points!

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
    It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
    The viewer will learn how to count occurrences of each item in an array.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now