.htaccess affecting my php includes

phillydigital

Hi there I have been on this one for days and I'm not too advanced forgive me.

If I have the following link

<a href="<?=$linkLocations?>">Best Locations</a>

with that variable defined so:

$linkLocations = $URL . '/best-locations';

and this in my .htaccess file:

RewriteEngine on          
RewriteCond %{HTTP_HOST} !^$    
RewriteCond %{HTTP_HOST} !^www\. [NC]    
RewriteCond %{HTTPS}s ^on(s)|    
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1 [NC]    
RewriteRule ^([a-zA-Z0-9\_\-]+)/$ subpage.php?page=$1 [NC]

and this in subpage.php:

if ($page == 'best-locations') {
        include($ROOT .'/display/bestLocations.php');
        $mainContent .= $locationContent;
    }

And bestLocations.php has sql queries etc. . . but because I'm getting a 404 I know I'm not even getting that far right? This is a downloaded version of a live site running on wamp if that helps. Your input is prized beyond words

EDIT - This was solved by removing the following lines from my .htaccess

# compress text, html, javascript, css, xml:    
AddOutputFilterByType DEFLATE text/plain    
AddOutputFilterByType DEFLATE text/html    
AddOutputFilterByType DEFLATE text/xml    
AddOutputFilterByType DEFLATE text/css    
AddOutputFilterByType DEFLATE application/xml    
AddOutputFilterByType DEFLATE application/xhtml+xml    
AddOutputFilterByType DEFLATE application/rss+xml    
AddOutputFilterByType DEFLATE application/javascript    
AddOutputFilterByType DEFLATE application/x-javascript  

ExpiresActive On    
ExpiresByType image/gif A2592000    
ExpiresByType image/jpeg A2592000    
ExpiresByType image/jpg A2592000    
ExpiresByType image/png A2592000    
ExpiresByType image/x-icon A2592000    
ExpiresByType text/css A604800    
ExpiresByType application/javascript A604800    
ExpiresByType application/x-shockwave-flash A2592000    
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">    
Header set Cache-Control "public"

</FilesMatch>
Daniel Marschall

There are many reasons why this fails.

The "HTTP 404: Not Found" response means that the script subpage.php (and therefore also bestLocations.php) was not called.

You might want to debug the rewriting process: How to debug Apache mod_rewrite

Does this .htaccess work?

Options +FollowSymLinks

RewriteEngine on          

RewriteRule ^([a-zA-Z0-9\_\-]+)/$ subpage.php?page=$1 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1 [NC]    

For testing purposes, I have removed the HTTPS relevant stuff, and I have also exchanged the two lines at the end, so that first "x/" gets replaced, and then "x".

Also, you mentioned that this code is downloaded from somewhere. Does this source mention something about the required environment? Did this downloadable system work on other machines?

Update PS: Just to be 100% sure that your server accepts .htaccess files: Try writing garbage in the .htaccess file, and see if you get a "HTTP 500: Internal Server Error" response. If not, then your .htaccess is not interpreted.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

.htaccess affecting my php includes

From Dev

Why is my php "if statement" not affecting my mysql query?

From Dev

php includes inside other includes

From Dev

PHP: How to hide my application folders in .htaccess

From Dev

CSS not affecting PHP

From Dev

PHP/JavaScript Not affecting selectbox

From Dev

htaccess routing http to https sometimes includes removed CodeIgniter 'index.php'. Why?

From Dev

Why is height not affecting my divs?

From Dev

Entity Framework affecting my domain

From Dev

Ajax in timer is affecting my server

From Dev

.htaccess Rewrite Rule not affecting GET on page

From Dev

Prevent htaccess from affecting ajax requests

From Dev

htaccess want to add www without affecting subdomains

From Dev

Prevent htaccess from affecting ajax file requests

From Dev

Php DateTime Add and Subtract not affecting

From Dev

PHP XML Output with includes?

From Dev

Php includes and html tags

From Dev

Missing PHP includes (.h)

From Dev

PHP - If statement errors with includes

From Dev

If I hide .php by .htaccess, I cannot login my web

From Dev

All my .htaccess redirects are going to index.php

From Dev

PHP - WAMP Server - Test my HTACCESS ErrorPage (not working)

From Dev

Unable to write a rewrite rule in .htaccess for my php website

From Dev

.htaccess rule to remove index.php from the end of my urls

From Dev

Unable to write a rewrite rule in .htaccess for my php website

From Dev

Activating .htaccess in my CodeIgniter project (Removing "index.php")

From Dev

Why .htaccess dose not route to my index.php?

From Dev

Understanding my .htaccess file in order to rewrite X to X.php

From Dev

Dockerfile not finding one of my includes

Related Related

HotTag

Archive