URL rewriting php xampp

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shaam
Forum Newbie
Posts: 20
Joined: Tue Jun 23, 2009 6:36 am

URL rewriting php xampp

Post by shaam »

Hi guys,

Im using php and xampp and i want to rewrite my urls from dynamic to static for SEO purpose and also to secure urls,

For Example let say i have a dynamic URL
http://www.widgets.com/product.php?cate ... oductid=10

and i want to convert it to this one
http://www.widgets.com/product/

How can i do this by using .htaccess in xampp ????

Thanks
BornForCode
Forum Contributor
Posts: 147
Joined: Mon Feb 11, 2008 1:56 am

Re: URL rewriting php xampp

Post by BornForCode »

Code: Select all

 
# Externally redirect extensionless URLs to add a trialing slash (this is non-HTTP-compliant and not recommended) 
RewriteCond $1 !([^/]+/)*([^.]+)$ 
RewriteRule ^(.*[^/])$ http://www.example.com/$1/ [R=301,L] 
# 
# Internally rewrite extensionless trailing-slashed URLs to php scripts 
RewriteRule ^([^.]*)/$ $1.php [l] 
 
shaam
Forum Newbie
Posts: 20
Joined: Tue Jun 23, 2009 6:36 am

Re: URL rewriting php xampp

Post by shaam »

Thank for yuor reply,please tell me where i should write this code ?? and what settings required in xampp ???

Thanks
SeaJones
Forum Commoner
Posts: 48
Joined: Tue Jun 30, 2009 5:40 pm

Re: URL rewriting php xampp

Post by SeaJones »

I've had issues with Xampp and url re-writing, I don't think it has the rewrite module installed as default. Run a phpinfo() command to see if you can see it listed.

If it is there, the code Bornforcode sent you goes into .htaccess in the same directory as the files you wish to affect., usually the site root.
shaam
Forum Newbie
Posts: 20
Joined: Tue Jun 23, 2009 6:36 am

Re: URL rewriting php xampp

Post by shaam »

Thanks SeaJones,

Yes i installed that mod_rewirite module by changing file httpd.conf,

But its not working yet,

Please send me sample .htaccess code if u have any ???
SeaJones
Forum Commoner
Posts: 48
Joined: Tue Jun 30, 2009 5:40 pm

Re: URL rewriting php xampp

Post by SeaJones »

Have you got a phpinfo output to check it's working properly? And which version of Apache are you running?

If you don't know what I mean, run this file on your Xampp install:

Code: Select all

 
<?php
 
phpinfo();
 
?>
 
and see if you can see mod_rewrite listed under the installed modules. If it's not there, then you don't have i installed correctly.

The code you need for htaccess was posted earlierby BornForCode, why not buy him a beer? ;)
shaam
Forum Newbie
Posts: 20
Joined: Tue Jun 23, 2009 6:36 am

Re: URL rewriting php xampp

Post by shaam »

Thanks for ur reply,

Yes as i told earliar that i have installed mod_rewrite and i checked it,
my php version is PHP Version 5.2.6,

there is no issue of mod_rewrite,the issue is in .htacess file.

do u have any idea why the apache server is unabled to call .htacess while url scanning???

is there any issue of code in .htacess or something else ?

Thanks
Post Reply