nepster
nepster

Reputation: 15

Removing .php extension with /

Well i know how to remove .php extension but i have a question.

www.example.com/one/two/three

In this type of address, what does "one" and "two" means. Are they folders or just link with out extension.

And how to create like this.

Upvotes: 0

Views: 100

Answers (3)

baldrs
baldrs

Reputation: 2161

Typically its an MVC route. It means controller/action/param.

You can create it using htaccess by redirecting request to index.php The following will skip existing files from being redirected to the index.php file, and they'll be served normally

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

After that, when request is passed to your index.php file, you can parse $_SERVER['REQUEST_URI'] or $_SERVER['QUERY_STRING'] and load classes that suit your request.

So if, for example, you have request news/read/1, you should find and call class News method read with argument 1.

Upvotes: 1

Padmanathan J
Padmanathan J

Reputation: 4620

Try this in your .htaccess file

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L, QSA]

Upvotes: 0

Shankar Akunuri
Shankar Akunuri

Reputation: 187

Those are can be folders or variables.. using htaccess u can create links like that..

Upvotes: 0

Related Questions