2

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 </IfModule> # 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?

15
  • 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.) Commented Aug 20, 2017 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 Commented Aug 20, 2017 at 17:26
  • Yes, Litespeed should just work the same as far as I know. What is the URL you are requesting? Commented Aug 20, 2017 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 Commented Aug 20, 2017 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. Commented Aug 20, 2017 at 23:38

1 Answer 1

0

The comments section is full so I'm linking my related answer:

https://serverfault.com/a/1083495/144798

To get local .htaccess working on Openlitespeed you first must generate those files AND then also point to those files within each virtual host AND ensure correct permissions. If you fail to do this, your websites might crash (fatal errors and/or 404 errors like this). Plus, you must reboot the Litespeed server every time you change .htaccess rules.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.