Skip to content Skip to sidebar Skip to footer

Sections Of Site Not Working After Modifying .htaccess File

I've just implemented Pretty URL's, taken from this question: htaccess question. Options +SymLinksIfOwnerMatch RewriteEngine On RewriteBase / # Ensure www on all URLs. RewriteCon

Solution 1:

Have it like this:

Options +FollowSymLinks
RewriteEngine On

# Ignore anything in js/css folders
RewriteRule ^(js|css)/ - [L,NC]

# Add www and turn on https in same rule
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]

# Adding a trailing slash
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]

# Remove index.php externally
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]

# remove .php externally
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,NE,L]

# Remove all .php extensions without interfering with .js or .css.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+?)/?$ $1.php [L]

Make sure to completely clear your browser cache before testing this change.

Post a Comment for "Sections Of Site Not Working After Modifying .htaccess File"