String replacement with htaccess? - .htaccess

Some of my sites sometimes get encoded url queries which will redirect to a error page but i would like to support some of these.
With htaccess how could you replace a url like this:
http://website.com/%3Fpage%3Dbdyb2y21ybar3h35
With this:
http://website.com/?page=bdyb2y21ybar3h35
Edit: I would like to do this directly within the .htaccess rather than decode with PHP etc.

Related

rewrite rule remove ugly code

i have reading different post but was't able to implement on my htaccess.
i have a url when i search on the page i get this url http://doman.se/module/spsearchpro/catesearch?fc=module&module=spsearchpro&controller=catesearch&orderby=name&orderway=desc&cat_id=2%2C4%2C9%2C6%2C5%2C10%2C8%2C7%2C11%2C36%2C37%2C50%2C21%2C29%2C22%2C24%2C23%2C53%2C31%2C30%2C32%2C52%2C12%2C13%2C39%2C25%2C14%2C33%2C34%2C43%2C35%2C44%2C40%2C51%2C15%2C16%2C20%2C19%2C41%2C49%2C42%2C46%2C45%2C48%2C27%2C38%2C28%2C47%2C54%2C55%2C56&search_query=general&spr_submit_search=Search&n=30
how can i remove the numbers 2%2C4%2C9%2C6%2C5%2C10%2C8%2C7%2C11%2C36%2C37%2C50%2C21%2C29%2C22%2C24%2C23%2C53%2C31%2C30%2C32%2C52%2C12%2C13%2C39%2C25%2C14%2C33%2C34%2C43%2C35%2C44%2C40%2C51%2C15%2C16%2C20%2C19%2C41%2C49%2C42%2C46%2C45%2C48%2C27%2C38%2C28%2C47%2C54%2C55%2C56
or make the url like this
http://doman.se/search_query=general

URL Rewrite keep %20 in Query String

I am trying to make a rewrite rule to move all pdf's on my site to point to a specific page and then use a Query String as the pdf's current file path to do a look up in a dictionary to see if that url is in my dictionary if it is redirect them to the correct page. The catch is my dictionary of urls has %20 and when I pull the query string it turns the %20 in a space. Thanks for any and all help.
Can you rewrite it to keep the %20 in the query string?
Example URL: /example/example/Big%20Small%20Something%20Pad.pdf
My Rewrite:
RewriteRule ([^/]*)\.pdf$ /redirectPDF.aspx?pdf=$1.pdf [NE,QSA]
Current Query String Output: Big Small Something Pad.pdf
What I want it to look like is Big%20Small%20Someting%20Pad.pdf
Try removing the NE flag. According to ISAPI docs:
http://www.helicontech.com/isapi_rewrite/doc/RewriteRule.htm:
noescape|NE
Don't escape output. By default ISAPI_Rewrite will encode all non-ANSI >characters as %xx hex codes in output.
So it looks like you simply want to omit the NE so that it'll encode the output like it does by default.
RewriteRule ([^/]*)\.pdf$ /redirectPDF.aspx?pdf=$1.pdf [QSA]

Redirect to URL with umlauts or accents via .htaccess

To redirect to a new URL that contains diacritics via .htaccess, what is the correct and safe way?
Can I somehow set the .htaccess file to UTF-8 and just use the non-ASCII characters, e.g.:
redirect 301 / http://www.bücher.ch/
Need I use the ACE string instead, e.g.:
redirect 301 / http://www.xn--bcher-kva.ch/
Is urlencode the way to go? I tried the following without success:
redirect 301 / http://www.b%C3%BCcher.ch/
For context, the following page on internationalized domain names (IDN) has a section about the technical solution to include accents and umlauts in domains.
In the domain part, you must use ASCII Compatible Encoding (ACE).
In the rest of the URL, you use urlencode. So, in .htaccess…
http://www.bücher.ch/schöne/
…needs to be written as…
http://www.xn--bcher-kva.ch/sch%C3%B6ne/

links includes coma and hash htaccess

I'm using links like that:
find.php?id=1&n=2#loc
I want to my links look like:
but i dont know how to change htaccess and when/where use # to link some place in the page #loc
htaccess:
RewriteRule ^(.*),(.*),(.*)$ $3.php?id=$2&n=$1 [L,NC,NS,NE]
Help lease
The #loc part of the URL is never sent to the server, so there's no way for you to match against it in your htaccess file. Anything starting from the # in the URL is called a fragment and it's used by the browser, the server doesn't know it's even there.

htaccess remove part of the url

I have urls structured like this:
/!#/pretty-url/
I need to remove the !# so the urls will look like this:
/pretty-url/
What would be the correct .htaccess rule to do this?
When you have a # in the URL then that is a named anchor. The browser does not send anything to the right of a # to the server. This means that all the rewrite engine is seeing is:-
/!
If you want your URLs to look like this then you are going to need to use JavaScript to get the relevant content via AJAX.

Resources