Forum
Htaccess rewrite issue
I am using this line in my htaccess to parse html as php to avoid changing all links in a medium size static site I have added Perch pages to.
AddHandler application/x-httpd-php5 .html .htm
I would like to add rewrite rules to allow friendly URLs ie. remove the .html
When I add the following code however the Perch admin area is not available I presume because the above is handling .html not .php
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Please advise on how I can remove the .html from URLs in root without affecting the Perch admin.
I assume I need htaccess rules to check both .html and .php?
Thanks
I can't provide URL as site is not accessible outside our network.
Perch: 2.8.4, PHP: 5.3.29, MySQL: 5.5.42, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.4), assets (2.8.4), categories (2.8.4), perch_backup (1.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/youandsea/public_html/perch
PERCH_CORE: /home/youandsea/public_html/perch/core
PERCH_RESFILEPATH: /home/youandsea/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 450M, Max POST 250M, Memory: 192M, Total max file upload: 192M
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/youandsea/public_html
HTTP_HOST: youandsea.com
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Appreciate any help or advice here. Thanks
Try:
Hi Drew Thanks for your swift response. I may not have been clear -
I have the correct htaccess rule for parsing html as php, that is working fine.
I would like to have friendly URLs however which means I need htaccess rules to rewrite BOTH .html and .php as the front-end site is all html and Perch of course is php.
I added a rule for html but it screwed up the Perch admin obviously as it was trying to find .html files in the admin directories.
Hope I'm making sense here. Thanks
The simplest thing might be to exclude the Perch folder from your rewrite rule.
Ah good idea.
Can I simply add an htaccess file in the Perch directory with RewriteEngine Off
?
If not can you suggest the best htaccess rule to rewrite all .html in the root excluding the perch foldr.
Many thanks
This seems to work for me -
Although this now adds .html after a friendly URL 301 - eg. /rya-shorebased-courses/
404 Error The requested URL /rya-shorebased-courses/.html was not found on this server.
I must admit my htaccess skills are not up to much!
Thanks
many thanks for your help.
Try:
Cool. Will try that and get back if still a problem. Again thanks.