Jump to content

Recommended Posts

So, with Apache, you can use a file named .htaccess. You put that file in your directory where your PHP resides and this will gives Apache instructions.

Apache is responsible for 'forwarding' your request to the PHP 'engine'. 

By default, all it will do is check the URL. If the filename ends with .php, it will try to tell PHP to execute that file.

But, with mod_rewrite (an Apache module), you can configure apache to change the URLs. For example, you can tell it to rewrite URLs with a certain pattern to another.

 

Here's a tutorial I found:

http://www.sitepoint.com/apache-mod_rewrite-examples/

 

Here's one I wrote myself (you can give me your comments if you read it):

http://www.mogosselin.com/friendly-url-for-php-with-apache/

 

If it doesn't work for you, you can query Google for 'php mod_rewrite tutorial' or 'php mod_rewrite example', etc. :)

I write in htaccess file next:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php?route=$1 [QSA]
</IfModule>

 

in PHP file is:

 

$route = explode("/", trim($_GET["route"], " \t\n\r\0\x0B/"));

 

so how can I split those variables, to make links in php files?

 

example

 

domain.com/content/main/header-of-text/155

 

content is the content file which is included into index.php

main is a some group of texts (name is stored in database - joined tables)

header-of-text is a header of the text stored in database - just writed

155 is the ID of text

 

without rewriting thats looks like domain.com?route=content&textgroup=7&id=155

 

...or am a totaly wrong... :(

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.