Want to trim url and use them as parameters - .htaccess

I am using this as a url:
http://localhost/easyappointments/info/vikram/45346346
My original path is http://localhost/easyappointments/index.php and rest /info/vikram/45346346 want to use as parameter. I will use explode() from php.
When I use this url, it says object not found.

if you want to use them as parameters then you could pass them as parameters in the url.
http://localhost/easyappointments/index.php?word_param=vikram&num_param=45346346
Or this answer shows you how to do it the way you're trying to do it
PHP passing parameters via URL

Related

Remove question mark from URL query

Is there any way I can remove the question mark from URL using Mod_Rewrite like this?:
domain.com/controller-name?parameter/parameter/parameter
to change question mark after controller-name to slash
domain.com/controller-name/parameter/parameter/parameter
I want to add this to htaccess in PrestaShop, where I send query like this: parameter/parameter/parameter to controller.
Normal Presta URL is domain.com/index.php?controller=controller-name and I set on SEO settings friendly URL to this controller to rewrite to only controller-name so SEO friendly URL is domain.com/controller-name .
To send some parameters to this controller I can use URL like this: domain.com/controller-name?(here parameters)
In my controller I grab parameters after question mark ? and show content according to this parameters. The parameters are separated by a slash. So I want to get rid of question mark and replace it by slash to get: domain.com/controller-name/(here parameters) with parameters I want to look like this domain.com/controller-name/parameter/parameter/
When I use URL domain.com/controller-name/parameter/parameter/ shows error 404 and Presta don't see that I want content from controller-name.
I think it is achievable by mod_rewrite rule in .htaccess, but I don't know how to write rule according to this problem.
OR maybe there is a way to add something to controller or SEO configuration in Presta to work with / instead ? in query... that would be great solution...
You can use the history.pushState and history.popState to change the URL in the browser which won't cause a page reload. But the problem is that old browsers don't support this.
Alternatively, you can set the window.location.hash property to a value that contains whatever state information you need, then either use the window.onhashchange event, or for older browsers that don't support onhashchange (IE < 8, Firefox < 3.6), periodically check to see if the hash has changed (using setInterval for example) and update the page. You will also need to check the hash value on page load to set up the initial content.
If you're using jQuery there's a hashchange plugin that will use whichever method the browser supports. I'm sure there are plugins for other libraries as well.
One thing to be careful of is colliding with ids on the page, because the browser will scroll to any element with a matching id.

Remove custom post type slug from wordpress url

My post URL is currently:
http://www.couponmartz.com/coupon/hellodemo-title
I want this URL to be like the following (without "/coupon"):
http://www.couponmartz.com/hellodemo-title.html
Is it possible removing it?
Thanks in Advance
You need to check out the register_post_type function. There is a $rewrite variable you can set to false or pass some custom arguments.
Reference http://codex.wordpress.org/Function_Reference/register_post_type

Encoding a URI parameters

Some of our GET request pass paramaters in the URI and in as a request parameter.
So in firebug you'd see the same parameter in the URI and you'd see it also on the params tab for the request.
When the parameter values needs to be encoded e.g. it is %, I see it encoded in the URI as %25 but I don't see it being encoded on the params tab.
The requests are being made using Angular.
I am wondering is it only when the parameter in the URI that it needs to encoded? Or do I need to be consistent here?
Thanks
you should encode your url/parameters using encodeURIComponent(url_or_params)
see: http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp

rewrite just the url in .htaccess and not change parameters passed to script with get

Is it possible to rewrite the URL part of a request but still pass the original request as a get parameter to php.
For example, my search url might be www.mysite.com/search/Search%20Request when the search request has been entered by the user and is multiple words, lower and upper case etc, I want to rewrite the url to all lowercase with no enocding signs etc, so the url is www.mysite.com/search/search-request but my get parameter gets passed correctly as &search=Search%20Request.
How can I rewrite just the url in .htaccess and not change the parameters I pass to my script with get.

Multiple and Variable parameters URL rewriting

I don't know how to rewrite URLs of this type:
mywebsite/param1-val1-param2-val2-param3-val3-param4-val4.html
that's really simple to do BUT my problem is that my parameters are variables like:
mywebsite/param1-val1-param3-val3-param4-val4.html
or
mywebsite/param3-val3-param4-val4.html
so, the number of parameters is not always the same. It can sometimes be just one, sometimes it can be 10 or more. It redirects to a search script which will grab the parameters through GET querystring.
What I want to do is to not write (on htaccess) a line for every link. The links are pretty simple in that form separated by a -(hyphen) sign.
Rather than rely on complex rewrite rules, I would suggest a simple rewrite rule and then modifying the code of your web application to do the hard part. Supporting this kind of variable parameters is not something that a rewrite rule is going to be very good at on its own.
I would use the following rewrite rule that intercepts any url that contains a hyphen separator and ends in .html
RewriteRule ^(.+[\-].+)\.html$ /query.html?params=$1
Then in your web application can get the parameters from the CGI parameter called params . They look like this now param1-val1-param3-val3-param4-val4. Your code should then split on the hyphens, and then put the parameters into a map. Most web frameworks support some way of adding to or overriding the request parameters. If so, you can do this without doing invasive modifications to the rest of your code.

Resources