开发者

htaccess not working on my VPS with cpanel

开发者 https://www.devze.com 2023-03-15 05:54 出处:网络
I have a website which was on a VPS with directadmin Control Panel, but I have just moved to another VPS with Cpanel. It used to work when it wan on the old VPS but in the new one I can’t make it wor

I have a website which was on a VPS with directadmin Control Panel, but I have just moved to another VPS with Cpanel. It used to work when it wan on the old VPS but in the new one I can’t make it work..!!

My script is CodeIgniter script and in this script this url:

www.mydomain.com/index.php/news

should be converted to:

www.mydomain.com/news

开发者_开发百科But after using htaccess, I can open the main page (which is index.php) greatly but when I want to go to www.mydomain.com/news (this should be defined as www.mydomain.com/index.php/news by htacces ) it shows me the main page. I have installed CodeIgniter (the framework I am using for my script) in the public_html folder (which is under home/user).

I have full admin access to my VPS, WHM/Cpanel and I can make any changes.

this is the .htaccess that was working for me in my old VPS:

Options FollowSymLinks
<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule> 

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

I have just found that by converting this line:

RewriteRule ^(.*)$ index.php/$1 [L]

to this one:

RewriteRule ^(.*)$ index.php/$1 [R]

means changing flag [L] to [R], it works, but it just converts www.domain.com/news to www.domain.com/index.php/news and shows in the addressbar and this not what I want.

Do you have any solution?! Should I change any configuration on Cpanel?!


Try this one:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond $1 !^(index\.php|images|css|js|favicon\.ico|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

Hope it works on your CodeIgniter install, I had the same problem and this solved it.

0

精彩评论

暂无评论...
验证码 换一张
取 消