WAMP Apache rewrite issue in .htaccess - apache

I am working in a WAMP environment trying to create a bare bones front controller and have started with creating an .htaccess file in my project root (i.e. www/molecule/ The .htaccess contains:
Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Apache rewrite_module is enabled in my WAMP settings, and also uncommented in the httpd.conf, but getting an Internal Server Error when I try to load any pages with that .htaccess in the directory. The Apache Error log reads:
[alert] [client 127.0.0.1] C:/wamp/www/molecule/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Can someone point me in the right direction?

It looks like you didn't turn on your mod_rewrite module. Find your httpd.conf file and do a search for mod_rewrite, the line should look something like this:
LoadModule rewrite_module modules/mod_rewrite.so
Make sure you uncomment that by removing the # in front of it.

if it is related to hosting site then ask to your hosting company or if you want to enable it in wamp local machine then check this youtube step by step tutorial related to enabling rewrite module in wamp apache
https://youtu.be/xIspOX9FuVU?t=1m43s
Wamp server icon -> Apache -> Apache Modules and check the rewrite module option
it should be checked but after that restart all services in wamp

Related

Ubuntu 15.10 Server 64-Bit .htaccess ? trying to enable but I am having no luck

I change a line in this folder etc/apache2/apache2.conf
with: AllowOverride None to AllowOverride All
and I make sure AccessFileName .htaccess is set correctly.
Then enable rewrite using this command:
sudo a2enmod rewrite
Then restart apache2:
sudo service apache2 restart
This is my simple .htaccess code:
# 1 ---- Establish a custom 404 File not Found page ----
ErrorDocument 404 /index.php
# 2 ---- Prevent directory file listing in all of your folders ----
IndexIgnore *
#block hotlinking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ style/logo/logo_icon.png [NC,R,L]
Then I get this when I access the main index.php file:
Forbidden
You don't have permission to access /index.php on this server.
Server unable to read htaccess file, denying access to be safe
Apache/2.4.12 (Ubuntu) Server at mydomain.com Port 80
The server system I am using is: Ubuntu 15.10 Server 64-Bit
I cant seem to figure out where I am going wrong, I am completely new with servers also done a good amount of research however I seem to still be limited on my abilities, I would appreciate any help :)

Apache ignore *.php files in rewrite directives but not other extensions

I'm trying to test some simple rewrite directives in .htaccess file on my test environment with Apache and PHP-FPM.
It seems that a simple rewrite rule works well for any type of file but not for *.php files.
This works :
RewriteEngine On
RewriteRule ^sandbox/video\.html?$ http://www.google.fr? [R,L]
But this not :
RewriteEngine On
RewriteRule ^sandbox/video\.php?$ http://www.google.fr? [R,L]
I run Apache 2.2 and PHP-FPM inside a VM on Debian
Could it be related ?
Thanks for your help
With PHP-FPM the .htaccess file is never read for php URL. You will need to add the rewrites to your main config.

Apache problems on AWS EC2 - URL path interpreted as sub-directory

I'm trying to migrate a website from cPanel based hosting to AWS EC2 and am having problems with URL Paths being interpreted as sub-directories.
for example www.mysite.com/page/page-name is giving the error in the apache error log /var/www/html/page/page-name not found.
I've hardly changed the Apache config file at all.
As you can see above the site is running in /var/www/http, I'm not using any vhosts
The site is written using the Yii framework on PHP
The home page display OK, so php and Yii are OK.
I have the normal htaccess file in the web root:-
RewriteEngine on
AddDefaultCharset utf-8
DirectorySlash Off
RewriteBase /
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
and in Yii configuration I'm using the usual urlManager config:
'urlFormat' => 'path',
'showScriptName' => false,
Is there something I should be adding to httpd.conf?
You may need to enable AllowOverrides in order for your .htaccess to take effect.
Look in your httpd.conf file and find the following line
AllowOverride None
Change this to
AllowOverride All
There may be more than one AllowOverride directive. The one you want to change is the one within the Directory stanza for /var/www/html.

phalcon routing does not work properly

I am having the same issue
My .htaccess file in project/ is
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
server : apache
and the command "a2enmod rewrite" shows that "Module rewrite already enabled"
when i point the browser to project folder i can see the folder structure , when i point to project/public then i can see "Hello world." I am using ubuntu elementary os. Am i Following correctly or is there any error in my installation.
when i point the browser to project folder i can see the folder structure , when i point to project/public then i can see "Hello world."
your server should be configured so you can't see the project folder from the browser, the root of your virtualhost should be the public folder
Is IfModule closed?
What you see when you go to another uri? Phalcon's error or Apache 404?
Try to disable mod rewrite, restart apache and then enable it again
a2dismod rewrite
service apache2 restart
a2enmod rewrite
service apache2 restart
I get this error to, but i don't know exactly how i fix it...

Friendly URLs EasyPHP

I'm trying to configure friendly URLs on my site, and get following error in my Apache error.log:
[Tue Mar 20 18:41:39 2012] [error] [client 127.0.0.1] script 'C:/EasyPHP/www/index.php' not found or unable to stat
I access my site like this: http://localhost/mysite
Site files are here: d:\Sites\php\projects\mysite\public_html\
My .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
I'm using EasyPHP 5.3.9 and Yii framework.
I've also uncommented this line in httpd.conf:
LoadModule rewrite_module modules/mod_rewrite.so
This has nothing to do with RewriteRule, it has to do with your EasyPhp installation. Just make sure that the website is properly configured (check for the vhosts configuration or maybe if there's only one site, the httpd.conf configuration).
Check the /protected/config/main.php file in the yii project and uncommnet the url manager. Here's some help -> http://www.yiiframework.com/doc/blog/1.1/en/final.url