"Friendly URLs" rule in .htaccess interfering with some directories

"Friendly URLs" rule in .htaccess interfering with some directories - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the "Friendly URLs" rule in .htaccess interfering with some directories error on your web browser. Problem :


My .htaccess is set up to remove .html from URLs as follows:



RewriteEngine on
RewriteCond %http_host ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,NC]
RewriteCond %REQUEST_FILENAME !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]


This is causing problems with the file /help.html, which now gives a 403 Forbidden error:



Forbidden

You don't have permission to access /help/.html on this server.

Additionally, a 404 Not Found error was encountered while
trying to use an ErrorDocument to handle the request.


Is there a way to keep friendly URLs and make the help page work?


Solution :

Try this



RewriteEngine on
RewriteCond %http_host ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,NC]
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_URI /help
RewriteRule . - [L]
RewriteRule ^([^]+)$ $1.html [NC,L]


I added a condition to your .htaccess to check if the Requested URI contains /help ,then it will be passed unchanged to its destination.


We hope that this article has helped you resolve the htaccess, redirects, url-rewriting error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=