regex - Why does my htaccess not rewrite properly -
i having problem htaccess file, , can't figure out if it's configuration, or server cache messing urls.
my file following
rewriteengine on rewritebase / rewritecond %{http_host} ^www\.(.*)$ [nc] rewriterule ^(.*)$ http://%1/$1 [r=301,l] rewritecond %{http_host} ^website.com$ rewritecond %{https} off rewriterule (.*) https://website.com/$1 [r=301,l] rewriterule ^([a-z]+)\/?$ $1.php [nc]
the first rule move www non-www, works.
the second rule move http https, works.
the third rule make url /anyfile
call anyfile.php
, keep lovely url.
the problem calls anyfile.html
, not php, , if remove said html file 404.
yes works typing anyfile.php in url, not have .php in url. if not obvious enough, supposed work file name, not single one.
any , appreciated.
replace .htaccess rules code:
options -multiviews rewriteengine on rewritebase / # single rule http->https , www removal rewritecond %{https} off [or] rewritecond %{http_host} ^www\. [nc] rewriterule ^(.*)$ https://website.com/$1 [r=301,l] # hide .php extension rewritecond %{request_filename}.php -f rewriterule ^([a-z]+)/?$ $1.php [nc,l]
Comments
Post a Comment