Eve Support Community
Forums
Eve Community
Customization Ideas
Cookie Woes? Quick Tip|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Groupee Member |
A few of you probably already know this but I thought I would post it as a helpful tip for others.
I got tired of checking for the 'eve' cookie to do quick things for my users only to have them complain about not seeing 'results'. This happens when they would come to a page using www.domain.com/... instead of domain.com/... I remembered that Apache has a mod_rewrite module but hadn't used it in some time. After a couple of attempts I came up with this. It will make sure you can always see that cookie if it is available. Here is what you need to do : 1 Create a file called .htaccess 2 Put the following code in it :
rewriteEngine On
rewriteCond %{HTTP_HOST} ^(www\.)?www.domain.com$ [NC]
rewriteRule ^(.*)$ http://domain.com/$1 [L,R=permanent]
3 Upload it to your root html directory Anytime a visitor types in or follows a link to www.yourdomain.com (and whatever else) it will get rewritten to yourdomain.com (and whatever else). Quick question for those of you who already knew this: 1. Is there a speed issue or noticeable delay when doing this? I tested it a bunch and couldn't perceive any problems. |
||
|
|
Groupee Member |
Hehe. I posted my reply to this topic on Evedev, but I suppose I'll post it here too, to get a second opinion...
I was having the exact same problem, but I took a slightly different approach to it (since I had no idea how to work mod_rewrite). At the very top of my application script, I have the following:
if ($_SERVER["HTTP_HOST"] == "www.se7enet.com") {
if ($_SERVER["QUERY_STRING"] != "") { $query = "?".$_SERVER["QUERY_STRING"]; }
die(header("Location: http://se7enet.com/index.php$query"));
}
So is it better/faster/safer to use the htaccess file? Or is PHP ok too? ---Jamin |
|||
|
|
Craftsman |
quote: I think it's about the same as far as speed goes. I think .htaccess is better if you have multiple files you want to have redirected. testing sigs |
|||
|
|
Groupee Member |
I'm going to be doing stuff on most of the pages on my site so the mod_rewrite will work best for me. I've been thinking about this some and although I'm no Apache / PHP expert I would think the Apache way would be faster:
Apache Mod_Rewrite URL Request www.domain.com/whatever URL Rewrite domain.com/whatever PHP Rewrite URL Request www.domain.com/whatever.php Server Parses PHP Code PHP Rewrites Location I doubt the speed savings is noticeable though. |
|||
|
|
Groupee |
The apache method is faster, but not noticably in most cases.
1) Server gets request 2) Server parses htaccess (if any) 3) Server redirects/rewrites as necessary 4) Server delivers content 1) Server gets request 2) Server parses htaccess (if any) 3) Server parses PHP script 4) Server redirects as necessary 5) Server delivers content |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|
Eve Support Community
Forums
Eve Community
Customization Ideas
Cookie Woes? Quick Tip
