Portal Home > Knowledgebase > Articles Database > Changing .htaccess
Changing .htaccess
Posted by hardjoko, 03-29-2007, 10:37 AM |
IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule !^index\.php$ index.php [L]
Hi,
This is my current .htaccess
As you see, it redirect all pages to index.php except index.php itsel
How do I modify it so that the exception is not just index.php but also channel.php or index3.php?
|
Posted by bear, 03-29-2007, 11:38 AM |
Perhaps this?
|
Posted by hardjoko, 03-30-2007, 02:31 AM |
Thanks a lot.
|
Posted by hardjoko, 03-31-2007, 01:09 AM |
index|index3|channel)\.php$ index.php [L]
What about if I want to spare index.php, index3.php, channel.php, and something.js
Would it be
!^(((index|index3|channel)\.php)(something\.js))$ index.php [L]
or
!^(index\.php|index3\.php|channel\.php|something.js)$ index.php [L]
|
Posted by foobic, 03-31-2007, 01:52 AM |
The latter. But you're probably better off with something like this:
ie. if the file exists, serve it. If not redirect to index.php, except if the request is for an image / stylesheet etc. - in that case send the 404.html page instead (which must exist, and should be small).
The point is that generating index.php may take significant memory and processing power - you don't want to do it for every missing image or stylesheet...
|
Posted by hardjoko, 04-02-2007, 09:24 AM |
Exactly what I need. Thanks.
|
Posted by hardjoko, 04-02-2007, 01:56 PM |
What happened if 404.html doesn't exist?
|
Posted by foobic, 04-02-2007, 07:43 PM |
Then 404.html will also serve index.php and you're back to generating the home page for every missing image.
|
Posted by hardjoko, 05-04-2007, 01:06 AM |
Ah ha.................................................
A way to solve it is then to just write in index.php to simply output an empty string when the $_SERVER['REQUEST_URI'] is 404.html
Another thing would be:
Hmmm... Is it possible to check whether index.php has been called twice by the same IP
Or how should I check? What should I detect within index.php so that if the query is just another js, page, etc it'll just quickly display an empty string.
|
Posted by foobic, 05-04-2007, 01:43 AM |
A way to solve what? Why don't you just create the 404.html file? (empty if you want it to be)
|
Add to Favourites Print this Article
Also Read