Re: [PHP] URL modification
tedd wrote: At 4:46 PM + 2/25/08, Nathan Rixham wrote: It may be a good time to throw in this .htaccess which just palms eveything [not found] off to php [.htaccess] RewriteEngine On RewriteBase / DirectoryIndex handle.urls.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /handle.urls.php [L] [/.htaccess] I use this for everything nowadays, in terms of security it also allows me to keep every script out of the web root; and joy of joys don't need to change any rules for static files, as they will always be "found" and thus the rules won't apply: follow? No, I don't. Please explain. Sounds cool. Hi, As far as I can follow, this looks much like a 404 redirect trick which captures all "not found" files/paths. Based on the extension, you can still do fun or cool stuff and get more control about virtual paths etc. As always: TIMTOWTDI, so I'm gonna play with this .htaccess rule and see if this is better than a 404 handler. Aschwin Wesselius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
At 4:46 PM + 2/25/08, Nathan Rixham wrote: It may be a good time to throw in this .htaccess which just palms eveything [not found] off to php [.htaccess] RewriteEngine On RewriteBase / DirectoryIndex handle.urls.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /handle.urls.php [L] [/.htaccess] I use this for everything nowadays, in terms of security it also allows me to keep every script out of the web root; and joy of joys don't need to change any rules for static files, as they will always be "found" and thus the rules won't apply: follow? No, I don't. Please explain. Sounds cool. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
I think this is a highly underused built-in feature. Agreed. I started to use it on my blog instead of a query string and pages reported by Google went up. -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Daniel Brown wrote: On Sat, Feb 23, 2008 at 6:27 AM, Richard Heyes <[EMAIL PROTECTED]> wrote: You could also forego the bit if you're willing to accept URLs like this: /rental.php/property/23425 I was waiting to see if anyone made mention of that while reading through the thread. I think this is a highly underused built-in feature. PHP is already, out-of-the-box, ready for search-engine-friendly URLs. It may be a good time to throw in this .htaccess which just palms eveything [not found] off to php [.htaccess] RewriteEngine On RewriteBase / DirectoryIndex handle.urls.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /handle.urls.php [L] [/.htaccess] I use this for everything nowadays, in terms of security it also allows me to keep every script out of the web root; and joy of joys don't need to change any rules for static files, as they will always be "found" and thus the rules won't apply: follow? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
> -Original Message- > From: Daniel Brown [mailto:[EMAIL PROTECTED] > Sent: Monday, February 25, 2008 11:37 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED]; php-general@lists.php.net > Subject: Re: [PHP] URL modification > > On Sat, Feb 23, 2008 at 6:27 AM, Richard Heyes <[EMAIL PROTECTED]> > wrote: > > You could also forego the bit if you're willing to accept URLs > > like this: > > > > /rental.php/property/23425 > > I was waiting to see if anyone made mention of that while reading > through the thread. I think this is a highly underused built-in > feature. PHP is already, out-of-the-box, ready for > search-engine-friendly URLs. > > -- > > > Daniel P. Brown > Senior Unix Geek > Yeap, PHP rocks! I mentioned it in the first reply, only that it was not rental.php, but index.php. Many if not all MVC frameworks support this kind of routing which doesn't require mod_rewrite. However, I prefer mod_rewrite if it's available, for crawlers it is not the same /index.php/my-keywrod than /my-keyword alone. But I must admit that there are a hundred other factors that can have much more weight for generating SEO problems than having index.php everywhere. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
On Sat, Feb 23, 2008 at 6:27 AM, Richard Heyes <[EMAIL PROTECTED]> wrote: > You could also forego the bit if you're willing to accept URLs > like this: > > /rental.php/property/23425 I was waiting to see if anyone made mention of that while reading through the thread. I think this is a highly underused built-in feature. PHP is already, out-of-the-box, ready for search-engine-friendly URLs. -- Daniel P. Brown Senior Unix Geek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
thnks Xavier Please consider the environment before printing this mail note. -Original Message- From: Nathan Rixham [mailto:[EMAIL PROTECTED] Sent: vendredi 22 février 2008 18:58 To: php-general@lists.php.net Subject: Re: [PHP] URL modification Richard Heyes wrote: >> H... made a quick look into it. >> Seems to be apache compatible. >> I'm designing a site to be hosted on an IIS Server. >> >> Does it still works there? > > On IIS I belive the default document is default.htm Though you should be > able to modify this to whatever you please. On Apache it is index.html > or index.php (for example). Regardless you want this to be parsed by > PHP, and then you can stick the following in it: > > header('http://www.example.com/login.php'); > ?> > > Place this file in your "login" directory and then you'll be able to > publish URLs such as http://www.example.com/login The trailing slash is > not necessary if login is a directory. For example: > > http://www.websupportsolutions.co.uk/demo > To use url's like http://domain.com/login/ as opposed to http://domain.com/login.php you can take multiple approaches. The first and simplest is to simply save your login.php as /login/index.php to use this approach you need to ensure that index.php is listed as a default page. In IIS you can set the "default" page(s) to be whatever you like: -> Open IIS Manager -> Server -> Websites -> Right Click [properties] -> select "Documents" tab -> ensure "Enable default content page" is ticked -> ensure "index.php" is listed -> if not then click [add] and enter index.php -> continue to add any other default pages [index.html, index.shtml etc] The second common solution [and I'd advise to get used to it asap] is to use URL rewriting. In short url rewriting involves defining "rules" which the web server uses to direct http requests to resources on the server. eg: direct domain.com/all_our_news to /index.php?newsitem=all a quick intro guide can be found here: http://www.sitepoint.com/article/guide-url-rewriting For URL rewriting in IIS use "ISAPI Rewrite" - http://www.isapirewrite.com/ in apache use mod_rewrite [apache1.3>] httpd.apache.org/docs/1.3/mod/mod_rewrite.html [apache2.0>] httpd.apache.org/docs/2.0/mod/mod_rewrite.html Both are pretty much identical when it comes to the end rewrite rules. Hope that helps a little Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
/rental/property/23425 to: /index.php?mod=property§ion=rentals&propertyid=23425 Thinking about this a little, you still don't need mod_rewrite. "rental" could be a PHP script, forced through PHP with: ForceType application/x-httpd-php In either a .htaccess file or, if performance is an absolute necessity, your httpd.conf file (ie .htaccess files are turned off). In your rental PHP script you simply look at the REQUEST_URI $_SERVER variable to determine the correct data to show. You could also forego the bit if you're willing to accept URLs like this: /rental.php/property/23425 -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Let's say we've got 2.5 million users :: weight up 2.5 million files vs 1 rewrite rule map: /rental/property/23425 to: /index.php?mod=property§ion=rentals&propertyid=23425 You never mentioned this many users. Hence you're moving the boundaries somewhat. finally, do you honestly not use mod_rewrite in anything you've made? No. -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Nathan Rixham wrote: > + rewrite is overkill for this, but long term it's worth implementing > and getting used to Completely agree. You've got to get to know url rewriting. I don't know how you can manage without it, even if it's far from always the right answer. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Richard Heyes wrote: + rewrite is overkill for this, but long term it's worth implementing and getting used to - think of the post as a pre-emptive strike on the inevitable question in a couple of weeks: "how can i make /profile/adam instead of profile.php?user=adam" Have a directory in your htdocs called /profile/adam and in that place a default document redirecting. Still no need for mod_rewrite. Unless of course you want the url to remain in the addressbar, but personally I don't think that is as important as what the user has to type in initially. Never thought I'd have to find a way to explain the benefits of url re-writing. [snip] /profile/adam and in that place a default document redirecting. Still no need for mod_rewrite [/snip] Let's say we've got 2.5 million users :: weight up 2.5 million files vs 1 rewrite rule map: /rental/property/23425 to: /index.php?mod=property§ion=rentals&propertyid=23425 SEO :: not even going in to this one finally, do you honestly not use mod_rewrite in anything you've made? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
+ rewrite is overkill for this, but long term it's worth implementing and getting used to - think of the post as a pre-emptive strike on the inevitable question in a couple of weeks: "how can i make /profile/adam instead of profile.php?user=adam" Have a directory in your htdocs called /profile/adam and in that place a default document redirecting. Still no need for mod_rewrite. Unless of course you want the url to remain in the addressbar, but personally I don't think that is as important as what the user has to type in initially. -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Per Jessen wrote: Daniel Brown wrote: On Fri, Feb 22, 2008 at 10:53 AM, Per Jessen <[EMAIL PROTECTED]> wrote: Nathan Rixham wrote: > To use url's like http://domain.com/login/ as opposed to > http://domain.com/login.php you can take multiple approaches. > [big snip] > Seriously, this is all overkill. Apache content negotiation does it all automagically and with minimal effort. Yes it does but the OP is using IIS. ;-P Oops, I missed that completely. Sorry. /Per Jessen, Zürich + rewrite is overkill for this, but long term it's worth implementing and getting used to - think of the post as a pre-emptive strike on the inevitable question in a couple of weeks: "how can i make /profile/adam instead of profile.php?user=adam" :) happy friday all -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Daniel Brown wrote: > On Fri, Feb 22, 2008 at 10:53 AM, Per Jessen <[EMAIL PROTECTED]> wrote: >> Nathan Rixham wrote: >> >> > To use url's like http://domain.com/login/ as opposed to >> > http://domain.com/login.php you can take multiple approaches. >> > >> [big snip] >> > >> >> Seriously, this is all overkill. Apache content negotiation does it >> all automagically and with minimal effort. > > Yes it does but the OP is using IIS. ;-P Oops, I missed that completely. Sorry. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
On Fri, Feb 22, 2008 at 10:53 AM, Per Jessen <[EMAIL PROTECTED]> wrote: > Nathan Rixham wrote: > > > To use url's like http://domain.com/login/ as opposed to > > http://domain.com/login.php you can take multiple approaches. > > > [big snip] > > > > Seriously, this is all overkill. Apache content negotiation does it all > automagically and with minimal effort. Yes it does but the OP is using IIS. ;-P -- Daniel P. Brown Senior Unix Geek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Nathan Rixham wrote: > To use url's like http://domain.com/login/ as opposed to > http://domain.com/login.php you can take multiple approaches. > [big snip] > Seriously, this is all overkill. Apache content negotiation does it all automagically and with minimal effort. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Richard Heyes wrote: H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? On IIS I belive the default document is default.htm Though you should be able to modify this to whatever you please. On Apache it is index.html or index.php (for example). Regardless you want this to be parsed by PHP, and then you can stick the following in it: http://www.example.com/login.php'); ?> Place this file in your "login" directory and then you'll be able to publish URLs such as http://www.example.com/login The trailing slash is not necessary if login is a directory. For example: http://www.websupportsolutions.co.uk/demo To use url's like http://domain.com/login/ as opposed to http://domain.com/login.php you can take multiple approaches. The first and simplest is to simply save your login.php as /login/index.php to use this approach you need to ensure that index.php is listed as a default page. In IIS you can set the "default" page(s) to be whatever you like: -> Open IIS Manager -> Server -> Websites -> Right Click [properties] -> select "Documents" tab -> ensure "Enable default content page" is ticked -> ensure "index.php" is listed -> if not then click [add] and enter index.php -> continue to add any other default pages [index.html, index.shtml etc] The second common solution [and I'd advise to get used to it asap] is to use URL rewriting. In short url rewriting involves defining "rules" which the web server uses to direct http requests to resources on the server. eg: direct domain.com/all_our_news to /index.php?newsitem=all a quick intro guide can be found here: http://www.sitepoint.com/article/guide-url-rewriting For URL rewriting in IIS use "ISAPI Rewrite" - http://www.isapirewrite.com/ in apache use mod_rewrite [apache1.3>] httpd.apache.org/docs/1.3/mod/mod_rewrite.html [apache2.0>] httpd.apache.org/docs/2.0/mod/mod_rewrite.html Both are pretty much identical when it comes to the end rewrite rules. Hope that helps a little Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
On Feb 22, 2008, at 2:09 AM, Xavier de Lapeyre wrote: Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? I do a version of this simply by creating a directory and then put a default file in... I have Apache set to recognize index.php, index.shtml, index.html etc. etc. etc. as default files, so when someone goes to www.raoset.com/contact/ the page that loads is: www.raoset.com/contact/index.shtml For my purposes it works great :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Xavier de Lapeyre wrote: > Hi all, > > I saw on some websites that modifies the links to access the webpages. > > Something like: > http://www.example.com/login/ > instead of > http://www.example.com/login.php > > Does anyone knows how this works or how its call / which PHP library > performs this action? It could be apache content negotiation that does it. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? On IIS I belive the default document is default.htm Though you should be able to modify this to whatever you please. On Apache it is index.html or index.php (for example). Regardless you want this to be parsed by PHP, and then you can stick the following in it: http://www.example.com/login.php'); ?> Place this file in your "login" directory and then you'll be able to publish URLs such as http://www.example.com/login The trailing slash is not necessary if login is a directory. For example: http://www.websupportsolutions.co.uk/demo -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
Quoting Xavier de Lapeyre <[EMAIL PROTECTED]>: Thnks, H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? Regards, Xavier de Lapeyre Web Developer Enterprise Data Services 24, Dr Roux Street, Rose Hill Office: (230) 465 17 00 Fax: (230) 465 29 00 Site: www.eds.mu Email: [EMAIL PROTECTED] Please consider the environment before printing this mail note. -Original Message- From: Andrés Robinet [mailto:[EMAIL PROTECTED] Sent: vendredi 22 février 2008 11:48 To: php-general@lists.php.net Subject: RE: [PHP] URL modification -Original Message- From: Xavier de Lapeyre [mailto:[EMAIL PROTECTED] Sent: Friday, February 22, 2008 2:09 AM To: php-general@lists.php.net Subject: [PHP] URL modification Importance: High Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? Xavier de Lapeyre That's called "URI/URL Routing" and it's usually performed as part of every MVC Framework I know of (CodeIgniter, CakePHP, Symfony, Zend Framework... just to name a few). It's usually implemented through Apache's mod_rewrite module, but you can get close without that module, if you allow for something like: http://www.example.com/index.php/myaccount/profile (that is, you don't need mod_rewrite unless you want to remove the index.php part of the URI path) However, if you have an existing website, migrating it to use one of the MVC frameworks (or just using a stand-alone URI Routing class) may not be the path you want to follow. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com There are rewrite modules for IIS also. Just google for IIS rewrite. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
Thnks, H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? Regards, Xavier de Lapeyre Web Developer Enterprise Data Services 24, Dr Roux Street, Rose Hill Office: (230) 465 17 00 Fax: (230) 465 29 00 Site: www.eds.mu Email: [EMAIL PROTECTED] Please consider the environment before printing this mail note. -Original Message- From: Andrés Robinet [mailto:[EMAIL PROTECTED] Sent: vendredi 22 février 2008 11:48 To: php-general@lists.php.net Subject: RE: [PHP] URL modification > -Original Message- > From: Xavier de Lapeyre [mailto:[EMAIL PROTECTED] > Sent: Friday, February 22, 2008 2:09 AM > To: php-general@lists.php.net > Subject: [PHP] URL modification > Importance: High > > Hi all, > > I saw on some websites that modifies the links to access the webpages. > > Something like: > http://www.example.com/login/ > instead of > http://www.example.com/login.php > > Does anyone knows how this works or how its call / which PHP library > performs this action? > > > Xavier de Lapeyre That's called "URI/URL Routing" and it's usually performed as part of every MVC Framework I know of (CodeIgniter, CakePHP, Symfony, Zend Framework... just to name a few). It's usually implemented through Apache's mod_rewrite module, but you can get close without that module, if you allow for something like: http://www.example.com/index.php/myaccount/profile (that is, you don't need mod_rewrite unless you want to remove the index.php part of the URI path) However, if you have an existing website, migrating it to use one of the MVC frameworks (or just using a stand-alone URI Routing class) may not be the path you want to follow. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
> -Original Message- > From: Xavier de Lapeyre [mailto:[EMAIL PROTECTED] > Sent: Friday, February 22, 2008 2:09 AM > To: php-general@lists.php.net > Subject: [PHP] URL modification > Importance: High > > Hi all, > > I saw on some websites that modifies the links to access the webpages. > > Something like: > http://www.example.com/login/ > instead of > http://www.example.com/login.php > > Does anyone knows how this works or how its call / which PHP library > performs this action? > > > Xavier de Lapeyre That's called "URI/URL Routing" and it's usually performed as part of every MVC Framework I know of (CodeIgniter, CakePHP, Symfony, Zend Framework... just to name a few). It's usually implemented through Apache's mod_rewrite module, but you can get close without that module, if you allow for something like: http://www.example.com/index.php/myaccount/profile (that is, you don't need mod_rewrite unless you want to remove the index.php part of the URI path) However, if you have an existing website, migrating it to use one of the MVC frameworks (or just using a stand-alone URI Routing class) may not be the path you want to follow. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] URL modification
Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? Xavier de Lapeyre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php