Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Need help with mod_rewrite
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Need help with mod_rewrite

YmpkerYmpker Member
edited April 2016 in Help

Heya,
So I am trying to install a codecanyon script which requires the following presets:

PHP Version 5.3+

cURL Extension (enabled on most hosts by default)

MySQLi extension (enabled on most hosts by default)

short_open_tags enabled

mod_rewrite enabled

Naturally, this shouldn't be a problem, yet I cant seem to get rewrite to work. I am running a LAMP stack on a Ubuntu 14.04 vps and as you can see in phpinfo (below) rewrite is supposedly enabled...
If I go to http://myipadress/login it doesnt work. When I go to http://myipadress/login.php it does.
Any idea why this doesnt work?

Here is my: php.info . As you can see all the other requirments are meet and so should be rewrite.

I have run "a2enmod rewrite" and the following settings in .htaccess

Comments

  • MadMad Member
    edited April 2016

    Make sure to use the following code in .htaccess:

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^([^.]+)$ $1.php [NC,L]

    Thanked by 1Ympker
  • @andreamada said:
    Make sure to use the following code:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^.]+)$ $1.php [NC,L]

    Thanks, will give it a try :)
    So Id replace line 3 of http://pastebin.com/xG5JGc5V with what you just posted?

  • exception0x876exception0x876 Member, Host Rep, LIR

    Do you have correct AllowOverride setting to allow usage of .htaccess?

  • MadMad Member
    edited April 2016

    @Ympker said:

    Yes, that's correct. Try and let me know, eventually you can even use this one if it's for login only:

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(login)/?$ /$1.php [L,NC]

    Thanked by 1Ympker
  • YmpkerYmpker Member
    edited April 2016

    Still doesnt work. No I havent done AllowOverride thing. What would I need to do? Thought I wouldnt need this as Im not having any vhosts.

    @andreamada

  • MadMad Member

    @Ympker said:
    Still doesnt work. No I havent done AllowOverride thing. What would I need to do? Thought I wouldnt need this as Im not having any vhosts.

    Have you tried with the updated rule given above?

    Make sure to upload the .htaccess in the root directory.

  • @andreamada said:

    Still doesnt work. .htaccess looks like this atm: http://pastebin.com/hq8Du39e

  • exception0x876exception0x876 Member, Host Rep, LIR

    @Ympker said:
    Still doesnt work. No I havent done AllowOverride thing. What would I need to do? Thought I wouldnt need this as Im not having any vhosts.

    Set "AllowOverride All" in the Directory config section of your website.

  • YmpkerYmpker Member
    edited April 2016

    @exception0x876 said:
    Set "AllowOverride All" in the Directory config section of your website.

    Would that go in /etc/apache2/sites-available/default ?

    Was returned this:

    • Restarting web server apache2 [fail]
    • The apache2 configtest failed.
      Output of config test was:
      AH00526: Syntax error on line 14 of /etc/apache2/sites-enabled/000-default.conf:
      AllowOverride not allowed here
      Action 'configtest' failed.
  • Ole_JuulOle_Juul Member
    edited April 2016

    Apache2 doesn't have htaccess turned on by default. I put your instructions here: http://quoque.su

    PS: can't paste code. I hate Cloudflare. (a lot)

  • YmpkerYmpker Member
    edited April 2016

    @Ole_Juul said:
    Apache2 doesn't have htaccess turned on by default. I put your instructions here: http://quoque.su

    PS: can't paste code. I hate Cloudflare. (a lot)

    The first part didnt even exist in my 000-default.conf
    will try

    • Restarting web server apache2 [fail]
    • The apache2 configtest failed.
      Output of config test was:
      AH00526: Syntax error on line 15 of /etc/apache2/sites-enabled/000-default.conf:
      AllowOverride not allowed here
      Action 'configtest' failed.

    EDIT: now it works thanks :)

  • exception0x876exception0x876 Member, Host Rep, LIR
    edited April 2016

    You have to put it inside the <Directory> section.

    Thanked by 1Ympker
  • MadMad Member

    I was going to say the same, enable Set "AllowOverride All", enable "sudo a2enmod rewrite" and restart apache.

    Glad to see that you got it working now :)

    Thanked by 1Ympker
  • @andreamada said:
    I was going to say the same, enable Set "AllowOverride All", enable "sudo a2enmod rewrite" and restart apache.

    Glad to see that you got it working now :)

    There is however still a problem:

    At my vps the landing page looks like this: http://46.38.237.40/

    However it is supposed to look like at my webhosting plan: http://test.nicos-web.com/

    So the only thing I can imagine is their difference in phpinfo/serverapi.

    vps uses apache2 handler webhosting fastcgi. could this be the reason why the one site works but the other doesnt?

    Not working site phpinfo: http://46.38.237.40/info.php

    Working site phpinfo: http://test.nicos-web.com/info.php

  • FalzoFalzo Member

    it's probably not an php issue after all.
    you're either lacking some files (esp. the css scripts and some more) at all, or your rewrite rules break it for those files to be accessed properly.

    Thanked by 1Ympker
  • K4Y5K4Y5 Member

    Looks like you have some file permission related errors -

    http://46.38.237.40/vendor/bootstrap-social/bootstrap-social.css Failed to load resource: the server responded with a status of 403 (Forbidden)
    http://46.38.237.40/vendor/landing/bg-header.jpg Failed to load resource: the server responded with a status of 403 (Forbidden)
    http://46.38.237.40/favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)
    http://46.38.237.40/vendor/bootstrap-social/bootstrap-social.css Failed to load resource: the server responded with a status of 403 (Forbidden)
    
    Thanked by 1Ympker
  • Aight thanks :) Something to look into tomorrow^^

Sign In or Register to comment.