You are here: Re: can you redirect every existing html page through a php function? « PHP Programming Language « IT news, forums, messages
Re: can you redirect every existing html page through a php function?

Posted by Stephen Kay on 09/27/18 11:43

> If you're running Apache, you could use a rewrite rule to redirect all
> requests for .html files which exist like this:
>
> RewriteEngine On
> RewriteCond /var/www/docroot%{REQUEST_URI} -f
> RewriteRule .* /var/www/docroot/fancy.php [L,NS]
>
> (untested, btw)
>
> and in fancy.php look at the $_SERVER["REQUEST_URI"] variable to get the
> name of the HTML which was requested. The RewriteCond will ensure the PHP
> is only called when the page exists. If you want to have 404 messages, you
> can remove that line, and maybe check for just .html. Personally, I have
> all requests for non-existing files going through a PHP file, to handle
> site-wide database connections, templates, etc.


Thanks dave -


> What server are you using?
> If you are using apache then you can use RewriteRule ... It will do exactly
> what you are after.
>
> RewriteRule ^([^/]+)/([^/]+).html$ /dopage.php?p=$1 [L]
>
> Then you can worry about what dopage.php actually does.


Thanks Simon -

I'll check them out!

--
Stephen Kay
Karma-Lab sk@karma-lab.NOSPAM.com
^^^^^^^

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация