I'm using litespeed on shared hosting (unfortunately), and I'm trying to use .htaccess to rewrite http to https NON www - and change domain.com/index to domain.com/my-string for SEO purposes.

This is working fine in Apache, and I didn't know my shared host was using Litespeed. I use the same .htaccess on litespeed which results in a 404, despite my filename being correct.

Here is my htaccess:

DirectoryIndex my-string.php

Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteRule ^$ my-string [L]

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^my-string$ /my-string.php [L]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
  AddType application/x-httpd-ea-php56 .php .php5 .phtml
# php -- END cPanel-generated handler, do not edit

The bottom section was added by my host.

This is working correctly in Apache, performs the 301 redirect from http non www, or http www to https non www with my string at the end of the URL, instead of index.

My understanding was litespeed uses the same syntax as Apache, so why is this happening?

  • So, your mod_rewrite directives aren't doing anything? Incidentally, if you've set the DirectoryIndex the way you have then you don't need the first internal rewrite (but that rewrite should come after the redirects anyway.) – MrWhite Aug 20 '17 at 17:22
  • @MrWhite Yes - I'm assuming that's whats happening. I was unsure whether litespeed needed anything different. I've tried looking at documentation online, but haven't found anything to solve this. Thanks for the pointers, this .htaccess really confuses me – user431951 Aug 20 '17 at 17:26
  • Yes, Litespeed should just work the same as far as I know. What is the URL you are requesting? – MrWhite Aug 20 '17 at 17:30
  • @MrWhite I've tried to request www.domain.com, domain.com which return a 404, BUT if I request www. or domain.com/my-keyword, then it works – user431951 Aug 20 '17 at 19:31
  • 1
    @MrWhite I've got in contact with my Shared Hosting company - this is one of the reasons why I hate using shared hosting, but unfortunately it's unavoidable for this site. I assume as my .htaccess rules are being ignored, it must be something to do with my host. Thanks for being so helpful, I really appreciate it. – user431951 Aug 20 '17 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.