Re: [PHP] Re: Preserving URL after redirect?
On Thu, March 6, 2008 6:42 am, Jochem Maas wrote: big boys use mod_rewrite, go grab a kilt :-) If mod_rewrite gives you the willies... You don't really NEED it here... Just don't create /wi/* directories, and use $_SERVER['PATH_INFO'] instead. Store all the school data somewhere else, and let the PHP/AJAX spew it out as needed based on the URL, with only an index.php file running the whole site. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Preserving URL after redirect?
Skip Evans schreef: (Apologies to Shawn for sending this directly to him and not the entire list, that was an accident. Here it is for the list.) Shawn McKenzie wrote: SNIP! Rewrite rule would look something like: IfModule mod_rewrite.c RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?path=$1 [QSA,L] /IfModule -Shawn My httpd.conf file has this LoadModule rewrite_module libexec/apache2/mod_rewrite.so But your .htaccess sample has IfModule mod_rewrite.c Is that okay? yes the 'IfModule' means only parse the directive in that block if the given module is loaded. Also, it does look like .htaccess is enabled in httpd.conf with entries like: # # AllowOverride controls what directives may be placed in .htaccess files. # It can be All, None, or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess But when I tried out Shawn's file I got 404 errors on the URLs (after renaming the wi directory, to be sure the .htaccess file was in control.) Any suggestions would be greatly appreciated. use a rewritelog as Shawn mentioned to see what apache is doing when it tries to rewrite the incoming urls. I'm going through a pretty good page on htaccess files at http://corz.org/serv/tricks/htaccess2.php But it starts off with Make no mistake, mod_rewrite is complex. *gulp!* big boys use mod_rewrite, go grab a kilt :-) Skip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Preserving URL after redirect?
Skip Evans wrote: Hey all, I have a weird issue that's got me pretty stumped, and I'm not sure I can do what the client is asking, or at least not how I'm trying to do it. I have a code base of my own I'm building sites on, fully AJAX enabled so that once the site loads it never fully refreshes a page, but AJAX runs everything through JS to server calls for content, updating only sections of the page only when needed, say for like the small calendar in the upper right corner when a new month is clicked. The site is basically a CMS for school sports teams to create their own pages, and the schools are accessed via individual directories like http://prepcube.com/wi/madison/ So I created the wi/madison/ ...directory when the school signs up and placed a file there that parses the URI to get the schools shortname, in this case madison, and then sets a session variables for school ID that allows the user to access this school's data. Then it redirects back to http://prepcube.com/ ...which of course loses the wi/madison portion of the URL, thought the client wants this preserved and to remain in the URL field. And since this is a fully AJAX enables site, the URL in the browser's URL field would never change from http://prepcube.com/wi/madison/ ...which is something the client really likes. So, my question is how would I do that, and I strongly suspect if it's possible at all an .htaccess file with the proper entries would be the way to do it, not using PHP code to redirect as I am now. Is this the case? Unfortunately, I must confess to not being terribly familiar with htaccess files, I believe this would be rewrite rules to rewrite the URL and point it to the right place? But even with htaccess rewrite rules could this be done to preserve the full URL with state/school in the browser's URL field? Any advice, as always, is greatly appreciated. Thanks globules! Skip Why create a real directory and put a file in it? Here is one approach: Client uses http://prepcube.com/wi/madison/ and .htaccess rewrites to http://prepcube.com/index.php?path=wi/madison index.php parses the path var to extract the short name and set the session var: Rewrite rule would look something like: IfModule mod_rewrite.c RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?path=$1 [QSA,L] /IfModule -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Preserving URL after redirect?
(Apologies to Shawn for sending this directly to him and not the entire list, that was an accident. Here it is for the list.) Shawn McKenzie wrote: SNIP! Rewrite rule would look something like: IfModule mod_rewrite.c RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?path=$1 [QSA,L] /IfModule -Shawn My httpd.conf file has this LoadModule rewrite_module libexec/apache2/mod_rewrite.so But your .htaccess sample has IfModule mod_rewrite.c Is that okay? Also, it does look like .htaccess is enabled in httpd.conf with entries like: # # AllowOverride controls what directives may be placed in .htaccess files. # It can be All, None, or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess But when I tried out Shawn's file I got 404 errors on the URLs (after renaming the wi directory, to be sure the .htaccess file was in control.) Any suggestions would be greatly appreciated. I'm going through a pretty good page on htaccess files at http://corz.org/serv/tricks/htaccess2.php But it starts off with Make no mistake, mod_rewrite is complex. *gulp!* Skip -- Skip Evans Big Sky Penguin, LLC 503 S Baldwin St, #1 Madison, WI 53703 608-250-2720 http://bigskypenguin.com =-=-=-=-=-=-=-=-=-= Check out PHPenguin, a lightweight and versatile PHP/MySQL, AJAX DHTML development framework. http://phpenguin.bigskypenguin.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Preserving URL after redirect?
Skip Evans wrote: (Apologies to Shawn for sending this directly to him and not the entire list, that was an accident. Here it is for the list.) Shawn McKenzie wrote: SNIP! Rewrite rule would look something like: IfModule mod_rewrite.c RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?path=$1 [QSA,L] /IfModule -Shawn My httpd.conf file has this LoadModule rewrite_module libexec/apache2/mod_rewrite.so But your .htaccess sample has IfModule mod_rewrite.c Is that okay? It Works for me and I have the same mod_rewrite.so line. Not sure the specifics of why this is as it is. Also, it does look like .htaccess is enabled in httpd.conf with entries like: # # AllowOverride controls what directives may be placed in .htaccess files. # It can be All, None, or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess But when I tried out Shawn's file I got 404 errors on the URLs (after renaming the wi directory, to be sure the .htaccess file was in control.) Any suggestions would be greatly appreciated. I'm going through a pretty good page on htaccess files at http://corz.org/serv/tricks/htaccess2.php But it starts off with Make no mistake, mod_rewrite is complex. *gulp!* Skip So you have the .htaccess file in the root dir alongside the index.php? I just tested and this is working for me. What I posted rewrites everything to index.php so if you have other php pages that are loaded by the browser then you would need better rules in .htaccess. To see more you might add the following and then check the log: RewriteLog /somepath/rewrite.log RewriteLogLevel 3 -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php