phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
ReWrite php vars including wildcards

 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » Apache mod Rewrite
::  
Author Message
somsak



Joined: 05 May 2007
Posts: 3
Location: Thailand

ReWrite php vars including wildcardsPosted: Sat May 05, 2007 5:49 pm    Post subject: ReWrite php vars including wildcards

I am in the process of finishing up a dynamic web and the only hurle left is to make the url s a little prettier.

Since I have heard that URLs with relevant words get better rank than numbers and codes I use list and $_GET directly on categories listed, subcategories and title such as

-www.mysite.com/article.php?category=My%20Category&subcat=In%20My$20category

i would like to rewrite this simply to be
-www.mysite/article/My_Category/In_my_category
if possible or
-www.mysite/article/category/My_Cayegory/subcat/In_my_category

My web server has rewrite enabled but on my windows system I cant get Apache rewrite to work so I would like to know what is the best way to do this before I start doing it.

Any help is appreciated since I ampretty new to these seo stuff
Thanx
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 14403

ReWrite php vars including wildcardsPosted: Sun May 06, 2007 10:49 am    Post subject: Re: ReWrite php vars including wildcards

And welcome Very Happy

On windows machine, you can use easyphp for example, you'd just need to proceed as follow to activate the mod_rewrite and be able to test all this locally :

To load mod Rewrite with Easyphp :
    Open EasyPHP1-8\conf_files\httpd.conf and un-comment
    (get rid of the "#" at the beginning of the required lines) those two lines :

    Code:
    LoadModule rewrite_module modules/mod_rewrite.so


    And :

    Code:
    AddModule mod_rewrite.c


Then, there are two separated part top work on to perform url rewriting.
First you need to actually rewrite the links, and this is to be done in the php files, and then to have these new url working, and this is the mod_rewrite part.
If we elaborate on this example of url : -www.mysite/article/My_Category/In_my_category
and assuming you won't have more than one sub level of categories, you could od the following :

In your .htaccess, add at the very bottom of it in case there are some other rewriterules (if not you' need to start the mod_rewrite before this) :

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-z0-9_-])/([a-z0-9_-])/?$ /article.php?category=$1&subcat=$2 [QSA,L,NC]
RewriteRule ^([a-z0-9_-])/?$ /article.php?category=$1 [QSA,L,NC]


Then, you'd need to have all outputted links following the standard here defined.

This means you'll need to format your categories and sub categories titles to make sure they only use a-z (letters) 0-9 numbers, _ underscores and - hyphens. And they will work Wink

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
somsak



Joined: 05 May 2007
Posts: 3
Location: Thailand

ReWrite php vars including wildcardsPosted: Mon May 07, 2007 7:45 am    Post subject: Re

Thank you for answering my questions.
I am have installed php 4.4.6 and Apache 2.0.59 om my windows computer since this is the version on the linux web server i am on. I do not find any
"LoadModule rewrite_module modules/mod_rewrite.so" in the Apache httpd conf file but the
LoadModule rewrite_module modules/mod_rewrite.so
is unquoted. But I cant get it work.
Have any suggestions or pointers for this ?

If I understand you right I need to rewrte my urls in PHP to get rid of the wildcard %20 (=whitespace)and then use .htaccess to remove the ? and &
and doing that is not really a problem
Thanx again
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 14403

ReWrite php vars including wildcardsPosted: Mon May 07, 2007 11:08 am    Post subject: Re: ReWrite php vars including wildcards

Well, the procedure to activate mod_rewrite is meant to work with easyphp, so I don't know about your set up.

I'm sure there are zillions of good tutorials to activate mod_rewrite on apache2 on the net, try a quick search.

Then, about titles, yes, it's better to avoid the url_encode() chars, the ones with %, like %20, %2F etc ...
Search Engines are able to deal with them, but still, I find it prettier without, more user friendly.

And since you need to re-build your links in order not to use the article.php?category=My%20Category&subcat=In%20My$20category anymore, you'd better as well format the titles nicely prior to injection.

Take a look at the demo forum, set it to advanced, a thread like : http://phpbb2.phpbb-seo.net/example-de-titre-mal-forme-vt85.html is a good example of the kind of filters required prior to title injection.

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
somsak



Joined: 05 May 2007
Posts: 3
Location: Thailand

ReWrite php vars including wildcardsPosted: Mon May 07, 2007 2:00 pm    Post subject: RE

Good point
again
Thanx a lot.
Beatiful forum.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » Apache mod Rewrite
Page 1 of 1

Navigation Similar Topics

Jump to: