Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


boostr.in questions - Question:.htaccess rewriting PATH_INFO vars to empty before passing to template; not removing index.php from url


got a two-parter for you: First (basic) issue that I'm trying to remove index.php from my links (which seems to be next to impossible thanks hostgator :) ). After a bunch of searching I've gotten to the point where /page redirects to /index.php/page. Now this is better than nothing, but of course still not ideal. And I had to use [R] to do it. My .htaccess is:

RewriteCond   %{REQUEST_FILENAME}   !-f
RewriteCond   %{REQUEST_FILENAME}   !-d
RewriteRule   ^(.*)$                index.php/$1  [R,L]
Second (hard) issue I need to find away to remove index.php from the url but still make sure the proper page controller (ie what page is in the url) is displayed. I'm using PATH_INFO to grab the var and display the proper page, and it works when the index.php is there.

But for some reason when you take the R out of that last RewriteRule, /page just always defaults to the main index.php template. It's like the .htaccess or whatever is rewriting PATH_INFO to empty before my site can process the page. I think I need to way to lock in PATH_INFO before the .htaccess rewrites it.

For some testing I stuck in var_dump(path_segments()); and when on /index.php/page it gives: array(2) { [0]=> string(0) "" [1]=> string(10) "proper-page" }. However, when you take the R out of the above rewrite rule and access without just /page, it just gives: array(2) { [0]=> string(0) "" [1]=> string(0) "" }.

Now I don't even know if I need to worry about the second issue if there's an easy way to do the first. But at least that's everything I'm trying to figure out now. Appreciate all the help I can get!

asked Sep 13, 2013 in htaccess by rajesh
edited Sep 12, 2013
0 votes
24 views



Related Hot Questions



Walkin Jobs Opening



Government Jobs Opening


...