mod_rewrite Issue

Linode Staff

Hello,

I am looking for some help, I've been trying for a couple of days to use the apache mod rewrite extension with an application that I have, i.e., PHP Pro Bid auction. It's written in CakePHP. I tried various directives in the apache2.conf default configuration file and the virtual host configuration file, but to no avail. Neither seem to be using the .htaccess file. I contacted the PHP Pro Bid support team, but they haven't been able to find a solution either despite trying numerous supposed solutions.

Is there any guidance you can provide me?

1 Reply

The best way to troubleshoot issues such as this are to first check if the components are active.

To check your .htaccess file Enter a random junk value into your .htaccess e.g. test any keyword not recognized by .htaccess and visit your URL. If it is working, you should get a

500 Internal Server Error

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request….

If you receive the error after the change it means apache is reading your .htacess file.

If you do not see this error I recommend checking the permissions and ownership of your file by running the below command in the directory where your .htaccess file is located.

ls -lha

This should tell you what user owns the file and what permissions it has. You can modify these permissions by following the below guides.

Modify File Permissions with chmod: https://linode.com/docs/tools-reference/tools/modify-file-permissions-with-chmod/

Linux Users and Groups: https://linode.com/docs/tools-reference/linux-users-and-groups/

To check if mod_rewrite module is enabled

1.Create a new php file in your root folder of your LAMP server. Enter the following

phpinfo();

2.Access your created file from your browser.

3.Ctrl F to open a search. Search for 'mod_rewrite'. If it is enabled you see it as 'Loaded Modules'

4.If not, open httpd.conf (Apache Config file) and look for the following line. #LoadModule rewritemodule modules/modrewrite.so

  1. Remove the pound ('#') sign at the start and save the this file.

  2. Restart your apache server.

  3. Access the same php file in your browser.

  4. Search for 'mod_rewrite' again. You should be able to find it now.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct