quickstopman Posted June 12, 2007 Share Posted June 12, 2007 hey guys im trying to figure out how to make s php page without an extension so basically instead of it saying "home.php" in the url it would just say "home" i know you can use subdirectorys but they get annoying does anyone know how to do this? Quote Link to comment Share on other sites More sharing options...
B34ST Posted June 12, 2007 Share Posted June 12, 2007 I dont know exactly how to do it but if u use apache you can use mod rewrite Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 12, 2007 Share Posted June 12, 2007 Have you read Hiding PHP? Some of the user notes may lead you where you want to go. Quote Link to comment Share on other sites More sharing options...
quickstopman Posted June 12, 2007 Author Share Posted June 12, 2007 hmm well my idea looks like this i want it to look cleaner but not make it comepletely neat so the urls would look like http://www.site.com/profile?action=action any ideas? Quote Link to comment Share on other sites More sharing options...
chigley Posted June 12, 2007 Share Posted June 12, 2007 You need a .htaccess mod_rewrite rule.. Quote Link to comment Share on other sites More sharing options...
quickstopman Posted June 12, 2007 Author Share Posted June 12, 2007 but what would i do in the .htaccess thats the question Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 12, 2007 Share Posted June 12, 2007 Are you using Apache as your web server, and do you have sufficient privileges to modify its configuration? If so, look at the Apache docs: link. Go read user contributed notes on the Hiding PHP man page again. And again. Believe me, it's covered there. Do you really need someone to go there for you, copy it, and post it here? WTF? Quote Link to comment Share on other sites More sharing options...
quickstopman Posted June 13, 2007 Author Share Posted June 13, 2007 ok here is what i have RewriteEngine on RewriteRule ^/home$ index.php RewriteRule ^/home/([0-9a-zA-Z]+)$ /index.php?action=$1 it doesn't work when i go to http://www.site/home i just get an error saying that directory doesn't exist any ideas?!?!? Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 13, 2007 Share Posted June 13, 2007 RewriteEngine On RewriteRule ^/home/?$ /home/index.php [L] RewriteRule ^/home/([^/\.]+)/?$ /home/index.php?action=$1 That works for me, except on "URL/home/" (the trailing slash gives a directory listing instead of the index.php/. I think that's fixable, but I don't know just how at the moment. You could probably also do something like the following for a more general case: RewriteRule ^/scriptdir/([^/\.]+)/?$ /scriptdir/$1.php RewriteRule ^/scriptdir/([^/\.]+)/([^/\.]+)?$ /scriptdir/$1.php?action=$2 See also: http://www.workingwith.me.uk/articles/scripting/mod_rewrite And Google "mod_rewrite"; there are lots of examples for this situation. Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 13, 2007 Share Posted June 13, 2007 <Location /home> Options -Indexes </Location> ^^^ Fixes the directory listing on a trailing slash problem. Quote Link to comment Share on other sites More sharing options...
quickstopman Posted June 13, 2007 Author Share Posted June 13, 2007 thanks for all the replys but.. none of them work at all i don't know why i have Apache installed the .htaccess file has the right syntax and it still doesn't work yeah so i think im gonna move on for now but if you have any ideas they'll help Quote Link to comment Share on other sites More sharing options...
gijew Posted June 13, 2007 Share Posted June 13, 2007 Just a quick question but are you running Windows or *Nix? I have 2 boxes as I enjoy developing on a Windows box but .htaccess are flakey at best on a Windows system. There are all sorts of work arounds but in the end you pretty much cannot get mod_rewrite to work in a Windows environment. This may not even apply but I figured I would give it a shot! Quote Link to comment Share on other sites More sharing options...
quickstopman Posted June 13, 2007 Author Share Posted June 13, 2007 Just a quick question but are you running Windows or *Nix? I have 2 boxes as I enjoy developing on a Windows box but .htaccess are flakey at best on a Windows system. There are all sorts of work arounds but in the end you pretty much cannot get mod_rewrite to work in a Windows environment. This may not even apply but I figured I would give it a shot! im not exactly sure what im running cause im just going into the control panal and edit the files but i think im useing linux Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted June 13, 2007 Share Posted June 13, 2007 Just a quick question but are you running Windows or *Nix? I have 2 boxes as I enjoy developing on a Windows box but .htaccess are flakey at best on a Windows system. There are all sorts of work arounds but in the end you pretty much cannot get mod_rewrite to work in a Windows environment. This may not even apply but I figured I would give it a shot! HUh! mod_rewrite works fine on my Windows dev box. The only tricky part is getting windows to create .htaccess files, you can't do it by right click > create new. I just go into notepad and save a blank file as ".htaccess" (including the quotes). Quote Link to comment Share on other sites More sharing options...
gijew Posted June 13, 2007 Share Posted June 13, 2007 I'm not going to screw up this guys post wildteen but how in the hell did you do that? I mean, it's been a while since I've tried getting it to work but I have tried everything I could find on the internet to get it to work several times and never once was successful. I know how to create an .htaccess just fine though If possible and if you get a moment mind contacting me outside this post to let me know the gist of how you got it to work on a Windows box? Sorry for hijacking your post here quickstopman but my eyes just got big! Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 13, 2007 Share Posted June 13, 2007 I wasn't using .htaccess files, rather putting everything in httpd.conf (or apache.conf in other installations). Your configuration must allow the use of .htaccess files for them to be "seen." Try putting your directives directly in the *.conf file. Allowing .htaccess files creates a performance hit and is usually disabled by default. 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.