NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Shorter URLs

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 05-07-2006, 11:58 AM THREAD STARTER               #1 (permalink)
New Member
Join Date: May 2006
Posts: 15
jpm6917 is an unknown quantity at this point
 



Shorter URLs


In your .htaccess file add:

Code:
<Files page>
SetHandler application/x-httpd-php 
</Files>
Now file "page" will be a php page without the file extension ".php"

www..com/page
www..com/page.php
jpm6917 is offline  
Old 05-07-2006, 12:31 PM   #2 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,792
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
I don't see why you would want to do that..

That would mess up folders, too. If you linked to a folder on your site without the trailing slash it would go to the foldername.php
Dan is offline  
Old 05-07-2006, 06:25 PM THREAD STARTER               #3 (permalink)
New Member
Join Date: May 2006
Posts: 15
jpm6917 is an unknown quantity at this point
 



Originally Posted by Dan Friedman
I don't see why you would want to do that..
????: NamePros.com http://www.namepros.com/code/194893-shorter-urls.html

That would mess up folders, too. If you linked to a folder on your site without the trailing slash it would go to the foldername.php
Not true, it would only go to "page" no matter what. I think you are confused. You are renaming the file to just “page” page.php does not exist anymore.


http://www.firstmortgageguide.com/articles

http://www.firstmortgageguide.com/forum
jpm6917 is offline  
Old 05-07-2006, 07:18 PM   #4 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,792
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Yes, so since you don't need an extension to make it PHP, if you went to site.com/folder it would go to folder.php and not the actual folder.

Say you linked to your forums (site.com/forums) that would do forums.php which isn't what you want.

You would have to make all links go to site.com/forums/

Plus, it only gets rid of .php.. not that big of a difference.
Dan is offline  
Old 05-07-2006, 07:35 PM THREAD STARTER               #5 (permalink)
New Member
Join Date: May 2006
Posts: 15
jpm6917 is an unknown quantity at this point
 



Originally Posted by Dan Friedman
Yes, so since you don't need an extension to make it PHP, if you went to site.com/folder it would go to folder.php and not the actual folder.
Understand your logic. This is just another way to make shorter URLs.

Then you can pass vars

www..com/page/var/

PHP Code:

????: NamePros.com http://www.namepros.com/showthread.php?t=194893
$var_array 
explode("/",$PATH_INFO);
$your_var $var_array[1]; 
Example, you can have this:

www..com/page.php?var=BLAH (Ugly!)

or you can have this:

www..com/page/BLAH/ (Clean and SEO friendly!)
jpm6917 is offline  
Old 05-28-2006, 09:22 PM   #6 (permalink)
NamePros Member
Join Date: Apr 2006
Location: NY
Posts: 32
cashboy is an unknown quantity at this point
 



I like the script... but is there any advanced version of it,..... i mean is there any class available that more sufficiently manages it?
__________________
- Steve :$: :)
cashboy is offline  
Old 06-03-2006, 12:43 PM   #7 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



Originally Posted by jpm6917
Code:
<Files page>
SetHandler application/x-httpd-php 
</Files>
That wouldn't change EVERY file? Just page.php?
????: NamePros.com http://www.namepros.com/showthread.php?t=194893

If I put "<Files search>" it would just be search.php? and not EVERY SINGLE FOLDER?

Am I right?

Thanks
Tom
PoorDoggie is offline  
Old 06-06-2006, 05:11 PM   #8 (permalink)
NamePros Regular
Join Date: May 2006
Location: London, UK
Posts: 779
vincenzo is a splendid one to beholdvincenzo is a splendid one to beholdvincenzo is a splendid one to beholdvincenzo is a splendid one to beholdvincenzo is a splendid one to beholdvincenzo is a splendid one to beholdvincenzo is a splendid one to beholdvincenzo is a splendid one to behold
 



What about using the mod_rewrite method:

PHP Code:
Add this to the .htaccess file on the root of your server:

RewriteEngine on
RewriteBase 
/
RewriteCond %{REQUEST_FILENAME}.php -f
????: NamePros.com http://www.namepros.com/showthread.php?t=194893
RewriteCond 
%{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule 
^(.+)/$ /$[R=301,L
That should just strip out the php extension of evry file.

- Vince
vincenzo is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:43 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger