How can i get mod_rewrite and .htaccess working with cakephp? - .htaccess

I'm trying to get cakephp working locally on my mac - yosemite. I have apache and php working locally in my /~user/Sites directory... I can hit a php ini file ok and have an install of wordpress in another directory.
I've hooked it all up apart from getting the urls rewriting... I followed the steps on the cake site:
http://book.cakephp.org/2.0/en/installation/url-rewriting.html
Now all I get is 404 not found!.
The three .htaccess files have the default content with an additional RewriteBase pointing to the folder its installed in, in my Sites folder.
Any ideas what I'm doing wrong? I've read the other posts on this and none of them helped!
Thanks

First, confirm mod_rewrite is enabled by (on command line):
# a2enmod rewrite
If it just got enabled using the command above, restart apache:
# /etc/init.d/apache2 restart
These types of errors should hit your error.log .. while trying to load the site, hold the error log open:
# tail -f /var/log/apache/error.log
and try to access your page again.
If this doesn't help you solve the problem, paste in your rewrite rules so we can take a peak.

Related

Virtual Host, works but any links get instant 404 error message

I created and setup a LAMP stack, inserted the database + files + code, and went to the local host. The main page pulls up (GOOD!) but, any links on the main page, no matter what it is.. gives me this:
Not Found
The requested URL /user/register was not found on this server.
Apache/2.4.18 (Ubuntu) Server at cbirc.com Port 80
I am assuming this is a apache issue? If someone could fill me in. Its strange that the main page pulls up fine, but any links to any other part of the site gives me this error code.
If index is working, It sound that RewriteEngine was not set to ON in apache configuration, Try to add this to your .htaccess file or vhost (/etc/apache2/sites-available/yourdomaine.com) :
<ifModule mod_rewrite.c>
RewriteEngine On
</ifModule>
If you modify vhost, don't forget to restart apache :
sudo apachectl configtest #Test before restart
sudo apachectl restart
if module is not installed :
sudo a2enmod rewrite
You can also check the Base URL in your HTML if you have one

CentOS 7 Apachect1 Removing a Virtual Host

[SOLVED]
I have a CentOS 7 VPS running Apachect1 and I have just finished a project that required me to create multiple subdomains. Now that I am done I do not need them so I want to go back and clean up a bit.
I had originally created the files
/etc/httpd/sites-available/site1.domain.com.conf
/etc/httpd/sites-available/site2.domain.com.conf
/etc/httpd/sites-available/site(...).domain.com.conf
and
/etc/httpd/sites-enabled/site1.domain.com.conf
/etc/httpd/sites-enabled/site2.domain.com.conf
/etc/httpd/sites-enabled/site(...).domain.com.conf
They were working and everything and all I thought I had to do to remove these domains were to delete those files and restart apache. I did this but I can still access these websites. Any idea?
I ran these commands:
# apachectl restart
# systemctl restart named.service
# systemctl start named
# systemctl enable named
# systemct1 status httpd.service
I have even restarted my server but nothing. Sorry if I missed anything obvious, I am still new to Linux. Thank you for any help.
there are several things you can do.
the first thing is to verify /etc/httpd/conf/httpd.conf to make sure how VIRTUAL HOSTS are defined in you file and if there are declared there.
Centos httpd config file
If there are no VIRTUAL HOST THERE. you will need to make sure that those files do not exist
/etc/httpd/sites-available/site1.domain.com.conf
/etc/httpd/sites-available/site2.domain.com.conf
/etc/httpd/sites-available/site(...).domain.com.conf
You could also try this commands
service httpd stop (to stop service)
service httpd start (to start service)
Let me know if this works :)
SOLVED
So I figured out how to work around this. I am not sure why but the issue was, anytime I went to a non existing subdomain I would get redirected to /var/www/SubdomainA/index.php
The way I worked around this was I went to each of my subdomains and added a rewrite condition in the .htaccess file that said, if the subdomain is not the specified subdomain, then send it to the main site.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www|SubdomainA)\.example\.com
RewriteRule .* http://www.example.com%{REQUEST_URI} [R=301]
Hopefully this will help someone at some point.

Unable to enable Clean URLs in drupal 7 website after migration

Recently, I migrated my website from local machine to server machine. The website URL is http://www.example.com/myweb
I noticed that only front page is visible and other pages are showing 404 error.
After reading this answer, I got to know that this is happening because of clean URL module. I enabled RewriteBase myweb in .htaccess file but It doesn't work out. Finally I thought of disabling Clean URL temporary as told here. This works well.
Now I wanted to enabled it again. It is showing following error-
Clean URLs cannot be enabled.
Below is the screenshot-
I can see some directory permissions error in status report at admin/reports/status. Are these related to each other?
You need to change your Apache server setting on new server.
Enable 'LoadModule rewrite_module modules/mod_rewrite.so' line in httpd.conf file on your server and restart server
Check if .htaccess works and also check if you have AllowOverrides All in your virtualHost config in Apache.

.htaccess redirect to subdirectory on Verio windows server

I've been trying to get a website up an running on my work's servers using Verio windows server 2003 gold and they've been quite useless when it comes to helping me out.
All I'm trying to do is set up a Wordpress installation, which they apparently require to be in a subdirectory. This is done and I have it in domain.com/wp ready to go. At this point they recommend that I use an .htaccess file to redirect to that url, so as they just sent me basically an "About .htaccess" link, that was of no help.
Did some searching, found a couple options like this one:
http://www.site5.com/blog/apache/htaccess/redirect-to-blog/20090427/
and nothing I use seems to work, not even as a straight redirect. Just gives me a "Directory Listing Denied - This Virtual Directory does not allow contents to be listed."
I do want to mention I did enable URL Rewrite for IIS via ISAPI_Rewrite 3 in the control panel.
As I mentioned Verio support is useless and I can't seem to find anything searching that seems to help my situation.
So pretty much what I need is domain.com/wp to rewrite as domain.com so all links centered around it do the same (ie domain.com/about domain.com/contact)
Any help? Thanks
If I understand you correct you need your Wordpress application to be available from the root of your web site instead of /wp/ folder? Then please try following .htaccess:
RewriteEngine on
RewriteRule ^(?!wp/)(.*) /wp/$1 [NC]
By the way I think you could try simply copying /wp/ folder content to the root folder.

Issues with mod_rewrite // Apache 2.2 // OpenSUSE 11.3

Apache Installed OK, LoadModule mod_rewrite is already uncommented in etc/apache2/httpd.conf, we've uncommented AllowOverrides and followed standard procedure for what is quite a simple install but .htaccess files are still taking no effect - are there any specific requirements for the setup above that would mean the mod_rewrite isn't working?
phpinfo() shows that mod_rewrite is loaded but we simply can't make any .htaccess file work, even with the simplest tests
RewriteEngine on
RewriteRule ^link([^/]*).html$ testrule.php?link=$1 [L]
Any ideas, anyone?
Another test to see if it's running is
lsof | grep mod_rewrite
I found after adding the 'rewrite' to the conf file and running the update
SuSEconfig
it still wasn't loading so I added it manually to this file as well
/etc/apache2/sysconfig.d/loadmodule.conf
After restarting apache all is working!
AllowOverrides could also be configured inside Directory tag, may be AllowOverrides is uncommented and On globally but is explicitly off in Directory tag.
Just a comment based on the provided information, it would be great if you could paste the related part of your httpd.conf.

Resources