talreja_sapna Posted October 12, 2006 Share Posted October 12, 2006 can anyone tell me how mod_rewrite worksactually i have uncommented the line in httpd file also but it is not wokingthankssapna Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted October 12, 2006 Share Posted October 12, 2006 it might be better to explain what you're trying to achieve - simply uncommenting something generally just makes things available for you to use rather than changing things automatically.mod_rewrite is about rewriting URL's. if you've seen wikipedia's URLS, or URL's without lists of parameters after the filename, then mod_rewrite is possibly at work.as it's generally done on a site by site basis, the best way is to create a text file in your webroot called .htaccess (notice the fullstop before the name).as for the rest - you need to decide what you want to achieve with the URL, get a grasp of regular expressions and go from there. Here's the main doc for it: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.htmlassuming you've already got that far, and it's not doing anything, do you have a: RewriteEngine On in your htaccess file?hope that helpsCheersMark Quote Link to comment Share on other sites More sharing options...
talreja_sapna Posted October 12, 2006 Author Share Posted October 12, 2006 hiactually wht i want is as soon as user register his homepage should be created(dynamic)example if user registers by the name johnthen he can visit his home page by the following urlhttp://domainname/johnthankssapna Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 12, 2006 Share Posted October 12, 2006 Whats your rewrite rules. Post your rewrite rulese here.You need to setup some rewrite rules in a htaccess file in order for http://domainname/john to work.Fo example. You have a file called profile.php and you use a url parameter called user, which profile.php uses to grab the details of that user. Instead having to type http://domainname/profile.php?user=user_hereYou want to use http://domainname/user_hereIn order to do that a rewrite rule needs to be setup for modRewrite to use. So your rewrite rule will be something like this:[code]# Tell Apache you want to use mod_rewriteRewriteEngine On# Setup the rewrite rulRewriteRule ^([a-zA-z]+)$ profile.php?user=$1[/code]You cannot just uncomment the mod_rewrite module and expect it to work just like that. Quote Link to comment Share on other sites More sharing options...
talreja_sapna Posted October 13, 2006 Author Share Posted October 13, 2006 hi thanks actually i am working with the mod_rewrite for the first time so for checking whether its working or not i had written the following in .htaccessRewriteEngine OnRewriteRule ^/alice\.html$ bob\.htmlif user try to access alice.html bob.html should be called but its not workingthankssapna Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 13, 2006 Share Posted October 13, 2006 Try this instead:[code]RewriteRule ^alice.html$ bob.html[/code] Quote Link to comment Share on other sites More sharing options...
talreja_sapna Posted October 13, 2006 Author Share Posted October 13, 2006 hithanksnow wht the problem i am facing is it is working on my system but not online can i load mod_rewrite module frm my code because it is not enabled on my domain(online)thankssapna Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 13, 2006 Share Posted October 13, 2006 No. You cannot enable the mod_rewrite in a htaccess file. All Apache modules have to be enabled via the server configuration (httpd.conf) file.Ask your host whether they can enable the mod_rewrite module. If they will not enable the module then you'll either have to find a new host, or upgrade your hosting plan to one where you can control the Apache configuration yourself (most probably a dedicated server plan) or dont use mod_rewrite. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.