Migrating CodeIgniter from WAMP to Ubuntu 12.04 LTS LAMP - .htaccess

After I successfully installed Ubuntu 12.04 LTS LAMP on my local machine, following this TUT. And installed phpmyadmin with this instruction. I migrated my working CodeIgniter project inside /var/www/ and updated my database. Everything seems to be working fine except i'm having a 404 error saying:
GET http://192.168.1.11/quantum/login/ 404 (Not Found)
The following error occured: error Not Found
GET http://192.168.1.11/quantum/user/ 404 (Not Found)
The following error occured: error Not Found
After hours of desperate troubleshooting I found some possible causes.
.htaccess (already updated)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
mod_rewrite (already enabled)
but still, i cant seem to make it work. any ideas? is there more to be configured to make the project running?

(dumb) Have you checked all folders have successfully been copied?
Have you changed your base_url in the config file? (/application/config/config.php)
When mod_rewrite is enabled (to remove the index.php in the URL), your index_page item in the config file must be blank.
If you have already checked these things, try disabling mod_rewrite in order to track if this is your issue.

Turns out I forgot to reconfigure my htaccess by allowing override on my httpd.conf inside apache2.
<Directory /var/www/quantum>
AllowOverride All
</Directory>
Works like peanut butter and jelly.

Related

Rewrite Rules Not Working in MAMP Pro Development Environment for Production Images

When working on a project, I would like to use the online images, so I don't have to download e.g. all images (as described here).
To achieve this, I wrote a view lines in my .htaccess-file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 8890
RewriteRule ^wp/media/.+ https://www.example.com:443%{REQUEST_URI}
</IfModule>
According to htaccess.madewithlove.be this should convert an image url from:
https://example.localhost:8890/wp/media/27442.jpg
to:
https://www.example.com/wp/media/27442.jpg
Context:
MacBook Pro
OS X Catalina 10.15.2
MAMP Pro 5.5.1
WordPress 5.3.2
example.localhost:8890 (SSL) up and running
local website is working fine
What I already tried/verified/adjusted:
How to get htaccess to work on MAMP
mamp pro htaccess rewriteRule not working
https://wordpress.stackexchange.com/questions/346778/rewrite-rule-to-load-images-from-production-does-nothing?rq=1
The .htaccess is being executed. When entering garbage, I got a error 500
Changed httpd.conf accordingly
Am I missing something? What else could prevent this from working?
The problem was that I had another .htaccess-file inside the wp-folder, because I moved the WordPress installation into its own directory (see here). When moving the rules into this inner .htaccess-file, it started working immediately.

Codeigniter and WAMP Routing Issue - What am I missing?

I'm scratching my head for almost two days now, thought some expert advice can help me here.
I got a CodeIgniter application I need to maintain (version 2.X), and this is my first experience with it. The structure of the application is:
myApp
application
cache
certs
config
controllers
...
modules
moduleA
controllers
models
views
moduleB
controllers
models
views
...
third_party
views
cgi-bin
...
system
themes
uploads
I installed WAMP, and throw the entire myApp under c:\wamp\www. Another steps I did:
1) Changed the 'listen' port of the Apache since I also run IIS on my machine.
2) Enabled the Apache rewrite module.
3) Set the 'all' and 'all granted' in the <Directory .../> section:
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
4) Set correctly the database name in the 'database.php' config.
5) Verified .htaccess file is located under myApp folder, and the content of the .htaccess is this:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
6) In 'routes.config' the default controller is: $route['default_controller'] = "login";
With these steps I was able to host this application locally and work for a while. But, I had to change my Windows user password, and after rebooting my computer I receive 404 errors all of a sudden.
I am able to browse to the 'login' page via http://localhost:port/myApp/index.php (or just http://localhost:port/myApp), but from there I receive only 404 error messages. I can browse with the full url though:
http://localhost:port/mpApp/index.php/login/forgotpassword - Accessible
http://localhost:port/myApp/login/forgotpassword - 404 error
Now, I am not sure whether it's related to my Windows user password change, but this issue became a voodoo, since I swear I could work and browse locally to all pages. I also reinstalled WAMP twice and repeated
the process above just to make sure I'm doing things right.
Can anyone think of something I am missing here?
Found the issue, at least the one worked for me:
In config.php (under ...myApp\application\config) I changed the value of $config['uri_protocol'] from 'AUTO' to 'PATH_INFO'.

modrewrite on cshtml files are ignored by mod_mono

I've got mod_mono and mono installed on my webserver and I'm trying to get this simple modrewrite working, however it seems to be ignored by mod mono.
RewriteEngine on
RewriteRule ^Projects/page1.cshtml$ /project2 [PT]
I have that in my .htaccess in the document root. If I use any other extension besides .cshtml, it works as intended. Any ideas?

XAMPP URL with 'error' end to 404 Not found

Is there some problem with URLs which have word error in them? Because if I enter route like http://eshop.local/controller/action, where controller can be anything at all, there's no problem, but if controller is error, it returns:
Error 404 Page not found
My htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
http://eshop.local/error works fine but if is followed by some action whatever word, number, or anything returns 404 error.
EDIT:
Just now i have copied it to my webhosting, everything with error urls is working fine, so problem is on XAMPP side.
Hold Your Breath
Open xampp control panel
Stop Apache
Click the Config button on the Apache row, and select httpd.conf
In that file, search for <Directory "C:/xampp/htdocs">
A bit lower, you may see a line like this: # AllowOverride All. Remove the #, which is a comment
Save the file
Restart Apache, say a prayer, cross your fingers and hold your breath
Response from Altrea, Moderator from XAMPP forum:
All URLs that are used in an Alias, Location or Proxy definition.
There are a bunch of them in XAMPP Apache (depending on which config files are activated or not some of them are maybe not used):
/cgi-bin/
/error/
/examples
/icons/
/licenses
/manual
/my-gateway/
/phpmyadmin
/php-cgi/
/security
/server-info
/server-status
/uploads
/webalizer
/webdav
In your case /error/ is already useds
Is it possible to reuse for example that /error/ or it' s better to change it in my code for example to /err/ ?
This Alias is used for the default Apache
error Pages (everywhere ErrorDocuemnt is used this Alias is used).
So it is possible to change it in XAMPP, but you have to
search and replace multiple files.

.htaccess not working on my server

I'm working on my project and now I want to transfer it from my localhost to server. Everything seems to work fine, but .htaccess doesn't work.
The server should be suporting mod_rewrite and print_r(apache_get_modules()); shows mod_rewrite running.
But still, when I type myaddress.com/contact, it shows error 404.
Here is the .htaccess file, but it should be fine, since it runs on my localhost:
RewriteEngine on
RewriteRule ^adminator/?$ adminator/login.php [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&detail=$2 [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
Do you have any idea?
Thanks, Mike.
Does the server allow .htaccess? It doesn't really have to.
Try other directives, ask your hosting provider, or check the configuration yourself if possible.
I tried testing your rules they should be fine on urls such as: http://myhost.com/test1 and http://myhost.com/test1/test2 result in requesting url: index.php?page=test1 and index.php?page=test1&detail=test2
So the problem is not your rules, it is your server setup somewhere. As Mewp said check your Apache config file, look for AllowOverride which should be enabled for .htaccess files to overriding default settings.
Ok, fixed it .. deep in the hostings settings, there was an option to activate it .. but I found it after 4 hours of looking around .. :P

Resources