Posted By

Abe on 01/14/08


Tagged

url php htaccess nice


Versions (?)

Who likes this?

308 people have marked this snippet as a favorite

section31
inetguy
damarev
niwoodbridge
llbbl
kdaviesnz
jonhenshaw
vilebender
luman
kiliksun
Cory
falp
bioascii
vincent
huze
jeff
Steffen82
tpms
Abe
leachypeachy
DFCNT
Morgano
hochitom
avioli
stphnclysmth
SpinZ
dyesin
Zidizei
zeljkoprsa
Akiva
ibomb
dryliketoast
Nix
romanos
liamchapman
willbolton
pixelhandler
chph
coylOne
ezerick
grn
jdstraughan
Dingdong
taboularasa
tikitakfire
Kerrick
nickdoherty
stavelin
atma
oriolfb
lzyy
Shocm
vali29
canberkol
maorb
danillos
iconsis
robe
jackii
zachwood
ascarion
baqc
Jdub7
ilumin
thermosilla
mikegreen
dzone
not_skeletor
kungpoo
nerdsane
PapTom
xtheonex
jstnjns
jpsirois
owais
cornellsteven
willwish
pgmr
kernelpanics
rezzz
nirva
ikimozu
grassdog
delarge
cybervaldez
dennyhalim
shingletown
brilliant
fragmentist
heinz1959
techmaster
thepuck
eapen
thadwheeler
uselessdreamer
gauravjassal
dizzley
cnsaturn
love
CSB
pauloc
acosonic
ginoplusio
NyX
ghostjam
codearachnid
coderiz
Gr33d
adanakahini
rene-design
nerdfiles
Pingpongbal
The14thGOD
smfinlay
leaase
lunacye
ruhanirabin
esoltys
sneaks
Knarf
risico
silentbob84
olragon
nefd
achilles283
bdaley
aherus
webtronix
ReeceMarsland
StrawMan
portalpie
Blacksnipe
ericschweichler
vikingmute
smoothdzion
eivind
novatvstdios
maxvee8
bradless
b123400
alvincrespo
abbey
Olli
oktijum
benrudolph
LyndseyPearce
frankyfish
rafaelmt
RM
rsavard
d0ri0
fazen
omardixon
fengelz
limenet
huylam
seloh77
kaartz
yves
jamwil
omerta83
alessio2
sonnh
NARKOZ
MicronXD
osirisinternet
fillyouin
jamepaul
ratzo
becky
lolindirfaelivrin
scottwf
jackkeller
microbians
jjjrmy
pytheas
shawntysco
ATLChris
fwd
vkolev
criso
pchengsf
mister
Darsain
mikael12
shalomfriss
koteus
fauverism
corangar
darkapple
pinyeiro
cjmling
seanpowell
bobbym245
ninjacharlee
jfoy
abdulaziz
hugeidea
AskoJr
armanx
beebs93
kuchenfari
bolven
zachdunn
connorjackson
poet
khejduk
sherlack
martins
mecha
userpiv
infinidad
pablo808
aricore
claudiowebdesign
barbietunnie
rmurillo020
0leg
mikaelholm
jirirybar
passion
proto
AlejoLuc
leond
tspitzr
andrewbowley
aegony
HalfWinter
polarbear
ilyasishak
asifjavedall
Hepamin
creativeboulder
o5kar
thefricky
mrplantain
santanajames
moopee1176
intothelight
svil4ok
qubestream
s3than
samkamerer
bkgoh
creatix
yellowkicks
bicho44
julianrhyswilliams
neex123
dymissy
nickian
wizard04
summer_charlie
crutzdesigns
tudisco
albertomori
Net-Freak
logiq
dechuck
benediktvaldez
czehner
jumichot
dayseye49
dubogii
merritt212
nathanbweb
Ideandro
ibbrxx
vaxxis
banjomamo
XjSv
rlynch3
skywalker
dixon
fjckls
voove
dsoms
joerugg
jatkins
macodev
tomenjr
loucypher
alberfp
jsamackay
mmcachran
ajhx
gearedtech
ApeWare
masta
adunaway
webod92
speckledjim
localsearchguy
clac
Koori
fvanommen
VadimG
clacwebstudio
A973C

itsmeameer
abhishekgoel137
ajcarrillo
ScottNYC
dendaak
imoddesign
CesarChavezNava
roopesh_777


Nice URLS PHP .htaccess


 / Published in: PHP
 

URL: http://spindrop.us/2006/07/26/how-to-remove-file-extensions-from-urls/

You can combine them with this: http://snipplr.com/view/4848/underscore-strings/

  1. .htaccess
  2. RewriteEngine On
  3. RewriteCond %{REQUEST_FILENAME} !-f
  4. RewriteCond %{REQUEST_FILENAME} !-d
  5. RewriteRule ^(.*)$ $1.php [L,QSA]
  6. # http://domain/about -> http://domain/about.php
  7.  
  8. --------------------------------------------------
  9.  
  10. .htaccess
  11. RewriteEngine On
  12. RewriteCond %{REQUEST_FILENAME} !-f
  13. RewriteCond %{REQUEST_FILENAME} !-d
  14. RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  15. # http://domain/about -> http://domain/index.php?q=about
  16.  
  17. <?php
  18. // $url_data is an array
  19. $url_data = explode("/",$HTTP_SERVER_VARS['PATH_INFO']);
  20. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jstnjns on February 19, 2009

For the first example, how would this work for sending variables? Like:

http://domain/about?var=something

Thanks!

Posted By: Unreal on February 28, 2009

I think this is a bit nicer

www.example.com.search.php?q=test to www.example.com.search?q=test

It works with any page too... so index.php, search.php whatever...

RewriteEngine On RewriteCond %{REQUESTFILENAME} !-f RewriteCond %{REQUESTFILENAME} !-d RewriteRule ^(.*)$ $1.php?q=$1 [L,QSA]

Posted By: tfotherby on January 7, 2010

Regarding the first rewrite rule: There is a alternative option: If you allow "Options MultiViews" in your Apache Virtual host configuration, Apache does an implicit filename pattern match and chooses from amongst the results - meaning URLs don't need to end in .php.

Posted By: buzzknow on September 17, 2010

u need to get segment function to catch any request in URL :)

Posted By: AskoJr on October 6, 2010

Thanks mate. I use this on my project and it works perfectly, variables like http://site.com/page?send=this works too.

Posted By: DanZam on November 20, 2010

How

Posted By: hippomegas on March 14, 2011

bit nicer thanks

Posted By: latope2014 on March 16, 2014

Free Zwinky Zcard Generator 2014 Working Proof 2014][Last Update March]

http://www.zwinkygenerator.besaba.com/

http://www.zwinkygenerator.besaba.com/

Create your own customizable ZwinkyCutie character. Become a Zwinky Cuties Jet Setter with a subscription in order to unlock cool special features.

1) Once the file is downloaded double click on the program and install 2)Enter username and select amount you want 3) Click Submit and wait for the generator to begin. 4) kick back and relax as you watch your zcard go up.

You need to login to post a comment.