Is http://localhost/index.php/controller/action?var=val valid? - url

Some PHP MVC has the index.php for the front controller. Now, my question is, putting a slash / and action after the document index.php makes it a valid URL? Also, does /action?var=val means that action is a file, not a directory? I'm really confused if I'll follow such URL format.
Thanks in advance!

It is a valid URL. In fact, with URL rewriting, pretty much anything can be a valid URL.
People often use the index.php/controller/action fallback if they can't rewrite the URL. It still works and they can access the URL used within PHP to still process it.

Related

Is there any way to encode the URL at runtime in rails?

In my rails application, I have search functionality. A user may directly enter a search string in the URL. If the user enters a search string as '%', the URL becomes:
http://localhost:3000/search/%
and that produces Bad Request error. Is there any option to encode the URL at runtime?
The question you're asking wouldn't actually solve the problem you're describing. Yes, Rails can encode a URL at runtime, in fact it encodes many URLs at runtime in its normal operation.
But, that won't help you, basically what's happening is that when your users create a URL with a % in it, they're actually creating an invalid URL - not just for Rails, but for any web server, or web application server or framework.
If you look closely at the error that you get returned in the browser, it's not even from Rails, it's from WEBrick (or whatever httpd you're using), same with the error that will be logged to your logs, it's not a normal Rails error in the Routing or elsewhere.
The upshot of all this is that no, you can't handle this in Rails because in many cases it won't even get through to Rails, and it's just a totally invalid URL.

Tracking template lpurl takes you back to the specified final url? How does it work technically?

According to this article, https://support.google.com/adwords/answer/6076199
When you define a final URL as your landing page, you can use URL options to manage your tracking and redirect information.
So, my website is example.com and the 3rd party service I use is called 3rdpartytracker.com
Let's say that I own the 3rdpartytracker website too.
http://www.3rdpartytracker.com/rd?keyword={_mykwid}&ad={creative}&url={lpurl}
Do I have to set a redirection script into 3rdpartytracker.com to send me back to the example.com ?
Or it will take me automatically back ?
I mean how does this work in a more technical approach ?
Thank you
If you own the both 3rdpartytracker.com and example.com then, yes, you will have to set a redirection script on 3rdpartytracker.com to extract the url parameter from the request to 3rdpartytracker.com and redirect to the url parameter value (in this case example.com).
I actually think that this blogpost provides a clearer explanation of Upgraded URLs in AdWords.
And if you can explain this to somebody else without mistakenly saying Final Destination then you're a better person than me!

Subdomain URL Rediretion In MVC

I am new in MVC, I have a list of url redirection:
•website1.domain.com goes to domain.com\websites\1
•website2.domain.com goes to domain.com\websites\2
This is a dynamic mapping like this: websiteN.domain.com goes to domain.com\websites\N
How can I do this in MVC, Do I need to use routing? or I need only URL redirection?
This is a duplicate question.
Everything you need can be done in IIS.
please visit this Stack link:
handling sub-domains in IIS for a web application
(same user asked this question and reposted How can we make an ASP.NET MVC4 route based on a subdomain?)
you can get more detailed information:
http://www.dotnetexpertguide.com/2012/04/aspnet-iis-dns-records-sub-domain-on.html
http://content.websitegear.com/article/subdomain_setup.htm
I've had a similar situation where I needed to make sure that the language code was in the url.
My solution was to write an http module. You'll want this module to inspect the request and see what subdomain the request is under. If it is a subdomain, then you'll want to redirect them to the correct directory under domain.com

Redirect all URLs ending in "#_=_" to Root Domain

Hi I am looking to create an htaccess redirect that takes
http://www.example.com/cooluser/profile#_=_ to http://www.example.com/cooluser/members/profile/
where /cooluser/ is dynamic and unique to the user that is logged in.
This is a buddypress installation.
Any help would be appreciated!
The URL's hash fragment (the part after #) is never sent to the server. The redirection needs to be done client-side, and can't be done in .htaccess.

When to use routes vs. rewrite rules?

I'm trying to debug a problem with routing and I've just realized that MVC routes do something extremely similar to url rewriting but I don't have a good understanding of which situations call for routing and which call for url rewriting. Can someone please explain where these two technologies differ and for which situations each is appropriate?
Url Rewriting analyzes the requested URL and changes it to a different URL on the same server. The URL rewriting module runs early in the request-processing pipeline, modifying the requested URL before the Web server decides which handler to use to process the request.
Routing is a request-dispatching mechanism that occurs after Url Rewriting. When a request is made to a Web server ASP.NET routing looks up the requested URL path in the list of registered routes. If the route is found, the corresponding handler for that route is invoked to process that request.
Use routes when you are developing a new application or maintaining an existing one. Use Url rewriting when you want to patch a legacy application without changing it internally.
http://www.iis.net/learn/extensions/url-rewrite-module/iis-url-rewriting-and-aspnet-routing

Resources