I have function that includes a htm file also title with the same name txt so it looks like "domain.com/details.php?content=Aboutus" I am thinking of changing this with sef urls like "domain.com/Aboutus" I have the htaccess examples. But could not figure out the a href part. Any ideas ?
you don't have to be bothered about the html tags (i.e. the <a href..> part)... for mod rewrite, the engine is only focusing on the actual urls and will know how to exclude the html tags.
What I mean by the href part is ; when I setup modrewrite everthing works fine. say that my link is domain.com/details.php?content=aboutus If I call domain.com/aboutus works fine. But my problem is what to write to href part. If I type "domain.com/details.php?content=aboutus" to href then this address comes up. The part that I need is the Php function that will allow me to call what ever the function would be to interprete the link from normal link (details.php?content=aboutus) to sef link (domain.com/aboutus) You see , I dont want my hrefs to be the sef type like .com/aboutus I need a function like <?link(aboutus);?> Code (markup): which will interprete the link. If modrewrite is working then address will come up as sef. If not address will comeup like old style not sef.
Maybe just create a config file where you can have a setting like: $cfg_rewrite = true; PHP: Then in your 'link' function you could just check the setting above like: function make_link($link) { global $cfg_rewrite; if ( $cfg_rewrite === true ) { return $link; } else { return 'details.php?content='.$link; } } PHP: I think I get what your saying, but maybe not.
Thanks.. This was exactly what I have tried to say. I will try this function. Perhaps improve a little. I will keep posting it from here.. Thanks
Just wanted to add: there's no 'native' PHP function that will convert your URLs for you (especially automatically), for a couple of reasons: 1) htaccess is an Apache thing. PHP needs to work with IIS and so on.. 2) there's no reason why you don't want to be able to access a page by both 'URLs'. chopsticks' example will work for 'simple' pages but once you get bigger, things will get messier...
Ofcourse I would like to access the URL with both ways. The part that I need is to create a PHP function that will dedect and write the href tag. So now by modifiying the htaccess file I can access the url as domain.com/ephesus and also domain.com/details.php?content=ephesus without doing any php work. But the href tag has to be either href="details.php?content=ephesus" or href="/ephesus" So I did not want to the href in the files to be either of them. I wanted to use like the chopsitcks linking function. href="<?make_link(ephesus)?>" BYTWY; I could not get chopsticks function to work So I have revised it alittle. // linking SEF $cfg_rewrite = true; function makelink($link) { global $cfg_rewrite; if ( $cfg_rewrite === true ) { echo $link; } else { echo "details.php?content=$link"; } } // linking SEF ends PHP: href tag is ; href="<?makelink("ephesus");?>" Code (markup): Thank you guys.. And for the htaccess I have done ; RewriteRule ephesus details.php?content=ephesus [L] RewriteRule about-us details.php?content=about-us [L] one by one. Is there way to include all these links on one line ? like : ^$link details.php?content=$link*
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html RewriteRule ^/(.+) /details.php?content=$1 HTH, cheers