Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 271 Vote(s) - 3.69 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom CMS, pretty permalinks like commercial CMS

#1
I am currently whipping up a very basic CMS for a personal project of mine. It is as much for my own education as anything. One question I have is how do I achieve url's / permalinks without file extentions. I understand using get variables to pull data from the DB but how do you convert this to something like

[To see links please register here]

instead of something like

[To see links please register here]

='blablabla.

Also on a slightly different topic can anyone point me in the direction of an EASY to use framework for developing sites that deal with memberships and member listings eg craigslist.

I currently develop within wordpress and am quite capable but am less familiar with OOPHP and custom CMS development from a base level.

Thanks in advance for any help or suggestions.

Reply

#2
This can be done simply via [url rewriting](

[To see links please register here]

) (in .htaccess placed in the root of your website directory structure).

Or you can rewrite everything to your index.php for example and then parse it here.

You just grab the URI part of the url from the [$_SERVER](

[To see links please register here]

) variable (take a look at 'QUERY_STRING' or just `var_dump($_SERVER)` to see which key contains what).

Here is the sample .htaccess file for rewriting everything:


RewriteEngine on
# rewrite everything except for assets to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php [L]
Reply

#3
File-less extensions are usually the result of an abstraction of the URL path - what this means is that your application should interpret everything after the URL and start presenting data based on that.

Consider the following:

`http://www.url.com/about-us`

On a normal HTTP request (on Apache, for example), Apache would try to serve a public folder called `/about-us`, and since it isn't specified, a static `index.php` file.

With any of the popular MVC frameworks, like CodeIgniter, CakePHP, Ruby on Rails, and so on, `/about-us` is matched to what is called a route, which loads assets relevant to that page. So instead of loading a static page, it runs out to a database, grabs the data for that page, grabs the template, and dynamically serves the file. That's essentially one way to get "pretty" URLs.

If you're looking to roll your own, I highly recommend any of the above frameworks. Don't just use them without understanding them, though - try to get a feel for what the execution process is. Get a grasp on what exactly each request does.

As far as authentication goes, I know there are a few options in Rails like Devise and CanCan. These are basically pre-coded authentication modules that allow you to easily configure them.
Reply

#4
You'd use a **.htaccess** file to pass all requests to your front controller (which is usually just an **index.php** script) and then that script matches the incoming request to a record in your database.

For example, if you had a database table called `pages` with four columns: `id`, `title`, `slug` and `content`, the following would be a simple implementation…

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php/$1 [NC,L]

This tells Apache to take all requests that aren't a file or a direction and send them to **index.php**.

Your **index.php** could then look as follows:

<!-- language: lang-php -->

<?php
// Take request URI
// Would be something like 'your-slug'
$request = trim($_SERVER['REQUEST_URI'], '/');

// Set up database connection and attempt to match slug
$sql = "SELECT * FROM pages WHERE slug = ? LIMIT 1";
$smt = $db->prepare($sql);
$smt->execute(array($request));

$page = $smt->fetchObject();

if (! $page) {
// Page was not found matching slug
header('HTTP/1.1 404 Not Found');
exit;
}

// Display matching page in a template

From here, you can then build upon it.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through