0

I recently added a mod rewrite rule to my htaccess file to handle parsing category pages. After receiving assistance on this site the htaccess works fine. However, after I implemented the new htaccess I noticed two different conflicts/problems occurring in my script.

1] I had to change all include() functions, script links, and image sources from paths to full urls for the script to function although I added <base href="/" /> just below the <head>.

2] Variables on included files, either through include(); or eval('?>'.file_get_contents($topad).'<?php;');, are no longer assuming their values pre-established on the page they are being called into.

For Example:

Prior to the rewrite rule being added to the htaccess file the below form worked just fine when included using include()... but after, though the form is being called to the page, the variables $level and $page_url do not assume their values.

echo '<form action="'.$level.'core/login/login.php" method="POST">';
    echo '<input type="hidden" name="returnto" value="'.$page_url.'">';
        echo '<div class="login-form-wrap">';
            echo '<fieldset><legend>Member Login</legend>';
                echo '<p>';
                echo '<label>Email</label>';
                echo '<input name="email" class="col_12" type="text" placeholder="Enter Email..." />';
                echo '</p>';

                echo '<p>';
                echo '<label>Password</label>';
                echo '<input name="password" class="col_12" type="password" placeholder="Enter Password..." />';
                echo '</p>';

                echo '<p>';
                echo '<input name="submitit" type="submit" class="button radius text-center expand" value="Log In">';
                echo '</p>';
            echo '</fieldset>';

            # forgot links
            echo '<p class="center">';
                echo '<span class="get-pass forgot-link" title="">Forgot Password</span> | ';
                echo '<span class="go-home forgot-link" title="">Go to Home Page</span>';
            echo '</p>';
        echo '</div>';      
    echo '</form>';

If I place the form on the file it works just fine.

However...

It should be noted that the file the form is being placed on is, in and of itself, a file being called through an include(); function and though the file is called through include();, everything works just fine.

I have no idea how to resolve this issue... your assistance is much appreciated.

Working htaccess:

# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymlinks -MultiViews
Options +SymLinksIfOwnerMatch -MultiViews
RewriteEngine On
RewriteBase /

# http -> https
RewriteCond %{HTTP_HOST} s8w\.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

# skip files and directories from rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^category/(.*)$ category.php?title=$1 [QSA,L,NC]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

RewriteRule ^(.+)$ index.php?title=$1 [QSA,L]
petebolduc
  • 1,233
  • 1
  • 13
  • 20
  • `https://www.s8w.org/category/restoration` – petebolduc Apr 16 '19 at 14:12
  • The line you see just below the banner that slides in is a header image which is represented as a variable on an included file – petebolduc Apr 16 '19 at 14:16
  • that is not the header... that is the top banner sliding in... the header image is a guy sitting on a doc with the word restoration on it – petebolduc Apr 16 '19 at 14:46
  • 1
    But `https://www.s8w.org/category.php?title=restoration` shows exact same page which doesn't get affected by any of the htaccess rules. – anubhava Apr 16 '19 at 14:50
  • I place the included file on the page which renders as desired so you can see... the header being called changes dynamically for other category pages, each with specific variables – petebolduc Apr 16 '19 at 14:54
  • 1
    `include` is server side directive that is all handled by php without causing any rewrite rule. So e.g. `mod_rewrite` is invoked first then php module is loaded where `$level` value is set in the php code. – anubhava Apr 16 '19 at 15:02
  • The bell rang in my head... the fact that `https://www.s8w.org/category.php?title=restoration` shows the same page is evidence it is not a htacces issue... do you have any idea as to what may be the cause? – petebolduc Apr 16 '19 at 15:02
  • It's been a while since I worked on PHP but check this Q&A https://stackoverflow.com/questions/4675932/passing-a-variable-from-one-php-include-file-to-another-global-vs-not/4676007 – anubhava Apr 16 '19 at 15:08
  • 1
    Thank you for your assistance... you have eliminated a major concern in my mind with your explanations concerning htaccess... I'll take a look at the php side of things – petebolduc Apr 16 '19 at 15:11

0 Answers0