Jump to content

simple PHP question


quickstopman

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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 :P

 

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.