mod_rewrite allow all characters and numbers and latters - .htaccess

([0-9a-zA-Z/+]+)
currently, I'm using this rule also I want + and % to be allowed in this rule how to do it? please help me

Your rule is already allowing +, you just need to add % into your regexp. It should be like that: ([0-9a-zA-Z/+%]+)

Related

svn2git kde rules errors - converting tags

I am using svn2git all fast export and I am getting the following error:
- I had my rules for tags along these lines:
match /(<folder>/Source/<folder>/[^/]+/)tags/
repository repo
prefix \1
branch refs/tags/\2
end match
How can I correct these rules?
As already told in the comments of your other question, it is probably the invalid backreference you use.
Your rule doesn't make sense.
You have one match group in your regex (thing in parentheses), but you use two back references (backslash + number).
I guess it's erroring out because of that.
Compare your tag rule to my example and you should see the difference.
You miss the ([^/]+)/ in the end of the rule

Need a mod_rewrite .htaccess solution to replace %20 spaces with -'s in the finished URL

I need an .htaccess mod_rewrite solution that will take a .cgi search query like this:
www.mydomain.com/cgi-bin/finda/therapist.cgi?Therapy_Type=Pilates Training&City=Los Angeles&State=CA
and return matching results in the browser's address bar to look like this:
www.mydomain.com/therapists/Pilates-Training-Los-Angeles-CA.html
or better yet:
www.mydomain.com/therapists/pilates-training-los-angeles-ca.html
Notice the database includes values with one, two or three words + spaces...
For example:
Therapy_Type=Pilates Training <- includes a space
City=Los Angeles <- includes a space
State=CA <- no space
I used the tool at: http://www.generateit.net/mod-rewrite/ to generate the following RewriteRule:
RewriteEngine On
RewriteRule ^([^-]*)-([^-]*)-([^-]*)\.html$ /cgi-bin/finda/therapist.cgi?Therapy_Types=$1&City=$2&State=$3 [L]
This does work (finds the search matches) and generates the results page, but because the parameter values have spaces in them, we end up with a URL that looks like this:
www.mydomain.com/therapists/Pilates%20Training-Los%20Angeles-CA.html
I've spent days in this forum and others trying to find a solution to get rid of these %20 (encoded spaces) so the final returned URL will look like 1) or 2) above.
I know someone on here must know how to do this... Help ;-)
If you replace the %20 with -, then how would you know where the therapy type ends and the city starts?
pilates-training-los-angeles-ca
would be
type=pilates
city=training
state=los
So I don't think you like to replace the %20 by -. You could however replace it with another character, like _:
pilates_training-los_angeles-ca
You then would have to translate every _ to a space within your PHP script (or whatever language you are using server side).

URL Rewrite with 3 parameters for forum .htaccess

I am trying to URL Rewrite to the following URL
Http://***.com/index.php?p=forum&mod=view_posts&page=$3&name=$2&id=$1
Http://***.com/forum/{id}-{name}/{page}
Http://***.com/forum/1-Hello-World/1
I have tryed the following code and have had no joy
RewriteRule ^forum/([^-]+)-([^&]+)/([^-]+)$ index.php?p=forum&mod=view_posts&page=$3&orderby=$2&id=$1
Thanks
That regex isn't very good: you see, the "([^&]+)" says: "one or more characters, up until the first ampersand", while you have no ampersands in the subject. Also, the "([^-]+)$" says "one or more characters before a hyphen", while you don't intend to end the subject with a hyphen.
Try this one:
^forum/([^-]+)-([^/]+)/(.+)$
But note that this actually captures any characters in the id and page positions, so you might be better off with
^forum/([0-9]+)-([^/]+)/([0-9]+)$
as that allows only numbers in those positions.
Also, you probably meant "index.php?p=forum&mod=view_posts&page=$3&name=$2&id=$1" instead of "index.php?p=forum&mod=view_posts&page=$3&orderby=$2&id=$1"

rewrite url with .htaccess

I need to rewrite a url like test.php?type=$1&val=$2
type will always be a string where as val could be a number or a string. I came up with the following
test/([a-zA-Z]+)/([a-zA-Z0-9|]+)/([0-9]+).html but as it was expected it will not work with something lke test/hello-world/23.html How can i included dashes in the expression?
You can escape them, so if you had
test/([a-zA-Z]+)/([a-zA-Z0-9\-|]+)/([0-9]+).html
This seems more like a question about regular expressions to me. test/([a-zA-Z-]+)/([a-zA-Z0-9|-]+)/([0-9]+).html should do. It's important to put the dash at the end of the character class.

'+' symbol in htaccess

I am using htaccess. I try to pass a value in url like 'C++'.
like "http://domain.com/Details/c++/detail.html"
I am retrieving the value in htaccess like
RewriteRule ^Details/([a-zA-Z_0-9_.,'&/-]+)/(([a-zA-Z_0-9_.,'&/-]+).html)$ index.php?page=$2&id=$1
But it returns only 'c'. Symbol '+' not accepted. I need the the value 'c++'.
Is there any solution?
Try Url encoding the + character.
"http://domain.com/Details/c%25%25/detail.html"
Is it possible to escape it, like http://domain.com/Details/c%25%25/detail.html. (I'm only guessing)
http://domain.com/Details/c%2B%2B/detail.html
A small consolation is: you are not alone. Since this problem is by design in URIs, eben big sites like Google have their problems with it:
http://www.google.com/search?q=c++
This does a search for just ā€œcā€.
Try it with the B flag:
RewriteRule ^Details/([a-zA-Z0-9_.,'&/-]+)/([a-zA-Z0-9_.,'&/-]+\.html)$ index.php?page=$2&id=$1 [B]

Resources