.htaccess issue in LiteSpeed Web Server - .htaccess

Need help with litespeed web server .htaccess rules.
http://example.com/temp/home.php is existing URL, but now what we need to rewrite is mentioned below:
http://example.com/temp.php?redirect=home.php
And our Existing .htaccess code is also given below.
RewriteEngine on<br/>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^temp/(.*)$ temp.php?redirect=$1 [QSA,L]
But I don't know the issue, this rewrite still not working and shows 404 error because temp/home.php does not exist.
These rules are working perfectly with Apache server, but not working with Litespeed
For reference:
https://htaccess.madewithlove.be?share=d15d3bca-6974-5682-902a-823c1a63e2b7
Thanks in advance.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^temp/(.*)$ temp.php?redirect=$1 [QSA,L]
The above code will serve the content of temp.php?redirect=home.php.
As a test I created temp.php in the root directory of a domain, with the content:
<?php
var_dump($_GET);
The result when accessing /temp/home.php is:
array(1) {
["redirect"]=>
string(8) "home.php"
}
This is tested on LiteSpeed Web Server 5.3.4 and 5.3.5.

Related

.htaccess mod_rewrite 500 Internal Server Error

I succeeded to use .htaccess with mod_rewrite for my first domain name.
I try to use it for a second domaine name, and I have for result "Internal Server Error".
However, I put the same files on their server, and they have the same configuration.
The content of the .htaccess file :
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Where can the problem come from ?
Best regards,
I found the solution, it's a problem with the encodage.
Getting Error 500 with this .htaccess on Linux, works fine on Windows

htaccess to nginx conversion reverse proxy to keep URL

i am using post affiliate pro and they have a script to turn a web page at www.example.com into a banner for affiliates, the htaccess uses a php script to load the affiliates info into the website/banner.
i am trying to convert the htaccess to nginx conf file. i have tried the converters at winginx and anilcetin
they work but it changes the url from www.example to pap.example.
on an Apache server with .htaccess the url is maintained www.example. this is what i am trying to duplicate on the nginx server.
here is the htaccess file.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/(.*) http://pap.example.com/scripts/page.php?a_aid=$1&a_bid=7c4ec277&a_file=$2 [L,P,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+) http://pap.example.com/scripts/page.php?a_aid=$1&a_bid=7c4ec277&a_redir=Y [L,P,QSA]
thanks for any help
Sean

RewriteRule not working as expected?

I am trying to implement a front controller. So I want to redirect requests to index.php. Here is my .htaccess.
RewriteEngine On
# Redirect everything to the Front Controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^(css|images|files)/ index.php [NC,L]
Currently, if I visit the following url, it works:
http://devserver/myapp/
But, if I visit any url that does not resolve to index.php, for example http://devserver/app/blog, Apache tells me that it cannot find index.php:
The requested URL
/absolute/path/to/myapp/index.php
was not found on this server.
But that path actually exists on my server, so I think what's happening is Apache is trying to access that url like a browser would - and it doesn't work because if I type in :
/absolute/path/to/myapp/index.php in my browser, it doesn't work. So, I decided to change the last line in my .htaccess to this:
RewriteRule !^(css|images|files)/ http://myapp.com/index.php [NC,L]
But it still doesn't work, because now when I check for $_SERVER[REQUEST_URI] in my PHP code, it always resolves to index.php because Apache made a HTTP request.
Anyways, can someone please tell me what I'm doing wrong, and I what I can do to make Apache redirect everything to index.php?
Thanks,
Not sure but try this.
RewriteEngine On
# Redirect everything to the Front Controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule !^(css|images|files)/ index.php [NC,L]
RewriteRule ^(.*)$ index.php/$1 [L]

codeigniter application works on hostgator but not another web host

I have a codeigniter application that is working perfectly on my hostgator hosted domain.
I have configured .htaccess and config.php to remove the index.php from the URL. As mentioned this is working 100%. I now need to move the application from my hostgator server to a local server in South Africa with Afrihost.
the modified htaccess and config file are shown below:
my htaccess file is:
RewriteEngine on
RewriteBase /
# Prevent CI index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
# Prevent user access to the CI system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Prevent user access to the CI application folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
and my config.php file is:
$config['base_url'] = 'http://logicoportal.co.za';
$config['index_page'] = '';
// let me know if you need to see any other setting
When I try to browse to the domain http://www.logicoportal.co.za I get error This page can't be displayed.
If I browse to my ion auth controller, http://logicoportal.co.za/auth/login I get 404 error The webpage cannot be found.
If I browse to my full codeigniter default path, http://logicoportal.co.za/index.php/auth/login I get error This page can't be displayed
I am assuming it is an htaccess configuration error however I am not sure how to correct this. read many an article with no luck. Alternatively is there another config setting in codeigniter to support this?
I have spoken to the new hosting company, Afrihost and they say they cannot help in this regard.
Any advice / direction would be appreciated.
Thanks as always.
Working Solution:
htaccess file to remove index.php on shared hosting server
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(index\.php|\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) ./index.php [L]
Try removing the ? in:
RewriteRule ^(.*)$ /index.php?/$1
So it's:
RewriteRule ^(.*)$ /index.php/$1

Expression Engine hide index.php not working correctly

I am working on a site that was working before someone else made some changes to the site. Now, I have to include index.php to the URL before the contact form will work.
Here is the htaccess file code I am using:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
What am I missing here?
Thanks.
The ? after index.php indicates to me that you're running PHP as CGI ... perhaps that was changed?
Also see: https://stackoverflow.com/a/11143216/174299

Resources