Search engine url

I am working on creating my first CMS search engine. I know that perhaps one of the biggest keys to having an SEO site is to have search engine friendly URLs. So, having a link like this:

http://www.mysite.com/product/details/page1

will result in significantly better ranking than that:

http://www.mysite.com/index.php?pageID=37

I know that for creating URLs such as the first, I have one of two options:

  • use web technology, in this case PHP, to create a directory structure
  • use the Apache add-in mod_rewriteto port these URLs to the PHP processor

As for PHP, I'm still comfortable. However, I think the first option will be more difficult to maintain.

Can someone show me how to write a file .htaccessthat will be:

  • silently directs the SEO URL to the script processor
  • not redirected if the requested URL is the actual directory on the server

Is there a better way than I'm trying?

+3
source share
2 answers

You can use .htaccess for Apache, create a file in the web root folder basically "htdocs" name it ".htaccess" add the following contents to it

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    Options -Indexes
</IfModule>

in your php file you can access data from $ _GET

$_GET['url'];

Then you can use the data to analyze what you need.

+7
source

Yes, the first option will be quite difficult to maintain. If you want to change the page title, you will need to recount all the pages.

- PHP product.php product/details.php $_SERVER\['PATH_INFO'\] , .

0

All Articles