• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 602
  • Last Modified:

mod_rewrite URL's with "anything" in the url

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 "domain.com/tag/journalistik+%26+Formidling" but the $_GET["data"] only get's "journalistik"

Any help will be appreciated :)
0
internetservice_dk
Asked:
internetservice_dk
  • 2
1 Solution
 
fiboCommented:
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 http://www.gerd-riesselmann.net/development/using-and-path-apache-modrewrite-and-php
My preferred solution there would be the solution 1
 Use the B rewrite flag: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_b
0
 
internetservice_dkAuthor Commented:
Thanks - works like a charm
0
 
fiboCommented:
B-) Glad to help. Thx for the grade and points!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now