php url-routing - php

I am studying php routing material now, but I still can't understand the theory. Does anyone here have good tutorials or links to share?

You are talking about url rewriting, and there are many other questions about that on here if you search for that term.
Regardless, url rewriting isn't handled by PHP, it's done by the web server. If you are running PHP under Apache, then you'll want to have a look at mod_rewrite. For IIS, you would look into the IIS Rewrite module (which conveniently can import mod_rewrite rules from apache as well)

Take a look at this: Url Routing with PHP

Related

Change url from localhost/name/index.php to localhost/name/home

I'm trying to change the name from my url's to for example home instead of index.php. I've read you can do that with the .htaccess file but for that you need Apache stuff and I don't have anything like that.
Isn't there any more easy way to change the url?
Yes, there is an easy way to change the URL without using the .htaccess file. This can typically be done by using a web framework or a CMS (Content Management System) such as WordPress, Laravel, or Django. These frameworks and CMSs have built-in functionality for handling URL routing, which allows you to define custom URLs for your pages.
Another way is to use a URL rewriting module provided by your web server software such as IIS URL Rewrite for IIS web server, or mod_rewrite for Apache. These modules allow you to rewrite URLs on the server side without requiring changes to the actual file structure on the server.
Without more information about your web server, it's difficult to give more specific instructions. But you could check the documentation or the community forum of your web server or the language framework you're using to find more information about how to change the URLs in your application.

Replicate Google App Engine app.yaml handlers in PHP outside of GAE

I am considering building my PHP project in Google App Engine (GAE), and I would like to be confident that I could easily port my code to a more standard Apache Tomcat & PHP server if needed. The one aspect that I cannot find a standard implementation for is GAE's app.yaml handlers. Let me define the functionality that I care about:
The ability to explicitly route incoming requests to a specific php script for fulfillment based on URL patterns.
My searches thus far have lead me to the Tomcat .htaccess RewriteEngine. However, it seems like this literally re-writes the URL and redirects the client machine to that URL. Am I wrong? Other than this solution, I have found nothing else that is promising. Can someone suggest a replacement for GAE's app.yaml handlers?
Thanks in advance!
Seems like you are looking for Apache mod_rewrite which lets you setup rewrite rules that are interpreted behinds the scenes and do not change the external URL.

URL pattern matching in PHP

I'm trying to implement java like url pattern matching in php. Suppose i have a link which leads to a file called find.php (Example is shown below)
http://www.xyz.com/MyWebsite/TryToFind/find.php?search=abc+def
Then i want to expose the follwing link to the users, say,
http://www.xyz.com/Search?search=abc+def
then i want to match this(2nd url pattern) url to the one i have provided above(1st url pattern) using a controller. This is because i want to hide the exact uri pattern to the user and also the hide the extension which i have used.
Please Help Me Guys...
Regards,
Abilash
If you are using apache (which I assume you are as you have tagged .htaccess) as your http server then you can use Apache's Mod_Rewrite Module. It usually ships with most installations of Apache these days and anyways you can install one yourself if it is not present.
Mod_Rewrite will enable you to achieve what you desire, In fact it is designed for that purpose only. While php frameworks like CodeIgniter provide some programming support for Mod_Rewrite, working directly with .htaccess using the Regex will render you with more power and flexibility.
A full explaination is difficult here. But this was the tutorial I found handy when learning the same.

URL re-writing in PHP

I am trying to implement URL rewriting in my PHP application. Can someone share a step by step procedure of implementing URL rewriting in PHP
In my application I want to implement following URL rewriting
http://example.com/fast-five
http://example.com/300
http://example.com/13-b
from
http://example.com/movie-download.php?nm=fast-five
http://example.com/movie-download.php?nm=300
http://example.com/movie-download.php?nm=13-b
One more thing which URL will be best according to SEO, management, application point-of-view out of the following two types.
Of course
http://example.com/fast-five
will be good for SEO
Are you serving your PHP through an Apache HTTP Server installation? If so:
RewriteRule ^/fast-five$ /movie-download.php?nm=fast-five [R=301]
From an SEO perspective, the first would be preferred. Using the HTTP 301 ("Moved Permanently") is most effective for this.
If your using an MVC framework like CakePHP, you should look at the documentation on routing. Otherwise, you can use the web servers rewriting rules.

How do you debug php web page that has pretty urls in zend studio?

I've read many tutorials on how to debug php web page like this one,
all are very good except that I don't see any of them take into account .htaccess.
So these solutions won't work for web pages that have pretty urls.
Has anyone figured it out ?
You need to take a look at the architecture of the site, and see what framework is being used. Each framework has different routing rules, which deal with the "pretty" urls.

Categories