2

Hi guys just want to ask this after hours of mod_rewrite frustration and reading tons of questions about it on stackoverflow because i tried everything and it didn't work with me. I don't know why, but i had enough so i searched about alternative and am asking here today for opinions. I came up with the following method.method

First assume I have this URL

http://www.domain.com/articles/6

and I have a articles.php page that will take the ID from this URL and pull the article content from the database (mod_rewrite fails in here), so this is a little solution:

$article_id=explode("/",$_SERVER["REQUEST_URI"]); 
show_article($article_id[3]);

the show_article() function will simply take the id and query the database for the article content and I read that the server will not understand that articles is a php page so a little solution too

<FilesMatch "^articles$"> 
  <  ForceType application/x-httpd-php >
</FilesMatch> 

so two questions :

1- will this solution affect indexing my website pages from search engines spiders ?

2- is this a good solution or mod_rewrite is better?

Note:am sorry if the question not will formatted am not good in formatting if you can make it look better i will appreciate it really sorry

6
  • Check out framework.zend.com/manual/en/zend.controller.router.html it redirects all traffic to index.php and then routes according to rules (you have something like that). Although mod_rewrite isn't hard to "learn"... Oct 21, 2011 at 13:44
  • thanks but i don't want to use zend framework and i know mod_rewrite isn't hard to "learn" but it's not working with me on basic rewriting
    – hollo
    Oct 21, 2011 at 13:46
  • I'm not saying that, Zend or any other framework, look at the principle. Oct 21, 2011 at 13:48
  • RewriteRule ^articles/([0-9]+)$ article.php?id=$1 [QSA,L] Oct 21, 2011 at 13:49
  • ah sorry i got it i will see that but what do you think about the method i talked about the problem man isn't rewriting rule it in the server i think
    – hollo
    Oct 21, 2011 at 13:50

1 Answer 1

1

Don't give up with mod_rewrite, it's a bit non-intuitive but VERY powerful and useful piece of software! You'll never get so clean solution in application regarding URL manipulation. To your question:

1) no, it'll not affect indexing. Both your solution and the one involving mod_rewrite are for web spiders transparent,

2) mod_rewrite is definitely better

I do recommend you to ask question regarding your problems with mod_rewrite not doing what you want. I'm pretty sure you'll sort it out with someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.