The content for my home page is pulled based on a query to the database using the slug 'home'. For example, if I enter example.com/home in the address bar, it queries the database based on seeing '/home' and pulls the correct content (using a variable '$path'). That part is working fine.
I also have a function that will redirect any unknown slugs direct to the home page. If I enter example.com/foo and there is no corresponding 'foo' record in the table, it will just serve index.php. Here is the function:
if(!isset($path['slug']) || $path['slug'] == '') {
header('Location:home');
}
I have looked at this answer and this answer which seem close, but aren't quite getting me what I need. I want 'example.com/home' to show as 'example.com' in address bar.
Also, here is my .htaccess:
# GZIP for speed
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# Removes any canonicalization issues
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ "http://example.com/$1" [R=301,L]
# RewriteRule ^/$ /home [L]
# RewriteEngine on
# RewriteBase /
# RewriteRule ^& http://localhost/example.com/home [L,R=301]
# RewriteRule / http://localhost/example.com/home [L,R=301]
# Restrict access to a variety of private file types
<FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
Order Allow,Deny
Deny from all
</FilesMatch>
# Disable directory browsing
Options All -Indexes
# Prevent folder listing
IndexIgnore *
# Let index.php handle all requests
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
# Dump referrer spam
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_REFERER} (?:o-o-6-o-o|bestwebsitesawards|s.click.aliexpress|simple-share-buttons|see-your-website-here|forum.topic55198628.darodar|hulfingtonpost|ilovevitaly|priceg|blackhatworth|semalt.semalt|kambasoft|buttons-for-website|BlackHatWorth|7makemoneyonline)\.com [NC,OR]
RewriteCond %{HTTP_REFERER} (?:lomb|lombia|econom|lumb)\.co [NC,OR]
RewriteCond %{HTTP_REFERER} (?:cenoval|Iskalko)\.ru [NC,OR]
RewriteCond %{HTTP_REFERER} (?:smailik|humanorightswatch)\.org [NC,OR]
RewriteCond %{HTTP_REFERER} (?:ranksonic|savetubevideo)\.info [NC]
RewriteRule ^ – [F]
</IfModule>
# Set the server administrator email
SetEnv SERVER_ADMIN admin@example.com
# Serve custom error pages
ErrorDocument 400 /template/400.html
ErrorDocument 401 /template/401.html
ErrorDocument 403 /example.com/template/403.php
ErrorDocument 404 /example.com/template/404.php
ErrorDocument 500 /template/500.html
Thank you in advance for help.