Django, Rails Routing ... Point?

I study web development (and college), so my apologies if this sounds naive and offensive, I certainly don't mean it. My experience was with PHP and with a small project on the horizon (an illustrious shift calendar). I was hoping to learn one of the higher level structures to ease the load on the code. So far I have been watching CakePHP Symfony Django and Rails.

With PHP, URLs are displayed very simply in files, and it "just worked." It was fast for the server and intuitive. But with all of these structures, there is such a tendency to โ€œgoodโ€ URLs by matching them with various functions and routing the parameters to different variables in different files.

The โ€œRails Way Bookโ€ I am reading admits that this dog is slow and causes most of the difficulties in working on fairly large projects. My question is: โ€œWhy is this in the first place?โ€ Is there a specific point in the url-maps-to-a-file paradigm (or mod_rewrite for a single file) that requires regular expressions and complex routing schemes? Am I missing something without using them?

Thanks in advance!

+6
django ruby-on-rails routing url-mapping
source share
6 answers
  • URLs should be easy to remember and say. And the user should know what to expect when he sees this URL. Matching a URL directly to a file does not always allow this.
  • You might want to use different URLs to display the same or at least similar information. If your server forces you to use 1 file mapping url โ†” 1, you need to create additional files, while all of their function will be redirected to another file. Or you use things like mod_rewrite , which is not as simple as displaying Rails URLs.
  • In one of my applications, I use a URL that looks like http://www.example.com/ username / some additional stuff / . This can also be done using mod_rewrite , but at least itโ€™s easier for me to configure the urls in the django project, and then in each apache instance I run the application in.

only my 2 cents ...

+6
source share

Most of them are already covered, but no one has mentioned SEO yet. Google puts a lot of weight on the URL itself if this url is widgets.com/browse.php?17, which is not very convenient for SEO. If your URL is widgets.com/products/buttons/, which will positively affect your button page rank

+6
source share

Saving application code in the web server document tree is a security issue.

  • incorrect configuration may accidentally show the source code to visitors.
  • Files embedded with a security vulnerability are immediately executed by HTTP requests.
  • backup files (created, for example, by text editors) can detect code or be executable in case of incorrect configuration.
  • old files that the administrator could not delete may show unintended functionality
  • library file requests must be explicitly denied
  • URLs show implementation details (which language / framework was used)

Please note that all of the above is not a problem if other things are not wrong (and some of these errors would be serious, even alone). But something always goes wrong, and additional lines of defense are good.

+3
source share

Django URLs are also very customizable. With PHP frameworks like Code Igniter (I'm not sure about Rails), you are forced into the / class / method / extra / URL structure. Although this can be useful for small projects and applications, as soon as you try to make it larger / more dynamic, you will run into problems and must rewrite part of the frame code to process it.

+2
source share

In addition, routers are similar to mod_rewrite , but much more flexible. They are not regular expressions and therefore have more options for different types of routes.

0
source share

Depending on how big your application is. We have a fairly large application (50+ models), and this does not cause us any problems. When this happens, we will worry about it.

0
source share

All Articles