Re: URL Parsing...
| From: | Jochem Maas | Date: | Sat, 24 Nov 2007 19:21:52 +0000 |
| Subject: | Re: URL Parsing... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265001@lists.php.net to get a copy of this message | ||
Amanda Loucks wrote:
> Hi,
>
> I'm working on redesigning the backend of the website for work. It was
> originally done in ColdFusion, but I'm switching it over to PHP - probably
> going to transfer the website from where it's currently hosted to something
> a lot cheaper, too, hence the switching to PHP. Anyway.
>
> Because we are a manufacturing company, we have a few different lines of
> products. Currently, each different product line has it's own page (and own
> meta tags). The current set up has ColdFusion grabbing the current page
> from the URL stripping off the '.cfm' extension and adding '-meta.cfm'
> before including it in the header.
>
> I'm sure there is a way to do this in PHP, but I'm out of shape enough with
> using PHP that I can't remember, and I can't seem to find anything that will
> work for me. I just want to be able to pull whatever address is in the URL,
> get the file name, and go from there.
>
> Any ideas?
one of these should give you something to go on:
echo preg_replace('\.cfm$', '-meta.cfm',
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)), "\n";
echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['PATH_TRANSLATED']),
"\n";
echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['SCRIPT_FILENAME']),
"\n";
>
> Anything would be helpful. :)
>
> Thanks,
> Amanda
>