First of All I'm not an expert on Linux, or even Apache, I'm used to work on Windows, WAMP where you just right clic on the icon and change the configuration you want to change.
Right now I have LAMP working properly, the only thing that is not working is the HTACCESS rewrite:
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
This is a common HTACCESS setup.
Everytime I write the URL: localhost/mysite/services it throws a 404 error.
You have to know that I've tried everything I've seen in Stackoverflow and Ubuntu forums.
1) When I check if the mod rewrite is active, it says it is
2) I created a "default.conf" file in "/etc/apache2/sites-available" and put this inside:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
3) I've restarted the apache2 service after that
Nothing seems to work, I'm desperated because I have to get this done for tomorrow.
EDIT:
This exactly configuration WORKS on Windows-WAMP and Production Server (hostgator)... I just pasted all the app to my Ubuntu Laptop and here, it is not working.
I am using apache2 in Ubuntu 14 and this works fine for me.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|hme|img|editor|tsd|wd|images|edi|js|fonts|assets|robots\.txt|css|blog)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hope this helps.
Related
I am having trouble getting my Laravel installation to work on my local server. It has been pulled from a server where it was working correctly but now none of the links work and I can't seem t get them working.
My WAMP Laravel installation is in the folder WWW (root folder of local server)...
Here is the /htaccesss (as it comes from the live server:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /~celeb/index.php [L]
Now, I know I will have to remove the '~celeb' part in the Rewrite Rule but when I do this the links still do not work. For example, when I click on a link such as "****/signup" it doesn't work, but when I add 'index.php' into it ("*****/index.php/signup') it works fine.
Does anyone know why this is happening as it is driving me crazy!
Thanks
I had the same problem and adding the RewriteBase rule to the .htaccess file did solve it.
Example for url : localhost/example/index.php :
RewriteBase /example
Then restart apache and maybe it'll work :)
Bests,
Kevin
I've created a .htaccess file in my document root at /var/www/html/ to rewrite URL of Codeigniter to remove "index.php" from URL of all pages.
e.g. Change URL from
http://myhost/index.php/controller/function
to
http://myhost/controller/function`
Here is the code of my `/var/www/html/.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I've got many suggestions from googling to enable mod-rewrite module, but I can see in my httpd.conf its already enabled.
LoadModule rewrite_module modules/mod_rewrite.so
This is perfectly working on my local system running on Debian 7 (Apache/2.4.4).
Any help would be appreciated. :)
You need to also specify the locations that can use it. For example, in /etc/httpd/conf/httpd.conf you should see something like:
<Directory "/var/www/html">
...lots of text...
</Directory>
Make sure is has:
<Directory "/var/www/html">
AllowOverride All
</Directory>
It's possible that your centos server isn't setup to handle PATH INFO. Try replacing the index.php/$1 in your rule's target to index.php?/$1.
Then you need to modify your CI config to enable query strings: http://ellislab.com/codeigniter/user-guide/general/urls.html
In you application/config.php file set $config['enable_query_strings'] to TRUE.
# CentOS Linux release 7.9.2009 (Core) -
# CodeIgniter 3.1.11 - ( .htaccess - This code work for me )
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
i have a .htacces on my server that is supposed to do this:
yo enter to ziced.com/cl/something and rewrites it as ziced.com/cl/index.php?var1=something, however is not working.
you can check that is not working by entering ziced.com/cl/faq versus ziced.com/cl/index.php?var1=faq
here is the .htaccess
AddHandler application/x-httpd-php5 .php
# This is the initialization
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
#Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
#chilean redirect
# /cl/var1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cl/([a-zA-Z0-9\.\*\°\~\,\%\"\'\+\(\)\-]+)/?$ /cl/index.php?var1=$1 [L,QSA]
I might know what the problem is but i dont know how to fix it. The webpage that has the rewrite rule, ziced.com, is an addondomain of metrikstudios.com
ziced.com points to metrikstudios.com/ziced/ so, maybe i should add something like:
RewriteRule ^ziced/cl/([a-zA-Z0-9\.\*\°\~\,\%\"\'\+\(\)\-]+)/?$ /cl/index.php?var1=$1 [L,QSA]
Solved the problem. Added the .htacces inside the subdirectory ziced (metrikstudios.com/ziced). Then it worked perfect.
Hope it works for someone in the future
I have WAMP v2.2 installed on my Windows 7 machine, with virtual hosts enabled.
I've successfully installed ExpressionEngine for one of my local sites, and everything works great except when I try to remove index.php from the URL using the approved .htaccess method. I still get a 404 error if index.php is not present, but the page displays fine with index.php in the URL.
I made sure the rewrite module was checked in the Apache menu:
. I've successfully used this method dozens of times on commercial hosts, so I'm stumped.
Update for pvledoux:
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>
Note: I tried adding the ? into the rule, but it didn't work.
The site is at the root of the Virtual Host.
Got It!
I needed to add AllowOverride in httpd-vhosts.conf:
<Directory "C:\Site\Root\Path">
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
A gagillion thanks and a 6-pack of beer goes to #parhamr for helping me out of this pickle.
A few possibilities here you could try out here:
[...]
RewriteEngine On
Options FollowSymLinks
[...]
Or:
[...]
RewriteEngine On
Options +MultiViews
[...]
Or:
[...]
RewriteEngine On
Options FollowSymLinks
Options +MultiViews
[...]
From my experience, Apache when running on Windows often needs one or both of those in order to do these kinds of things correctly. It might also straight up 500 on you, but these have worked for me in the past.
try to add RewriteBase /
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>
and check for sure that mod_rewrite is active in phpinfo
Have you checked your default document in Apache? If you are removing index.php physically from the machine and it reports a 404 on just a directory, www.domain.com/home/ that means Apache is looking for index.php still.
Is mod_rewrite turned on in the Apache?
I am using ExpressionEngine and want to remove index.php from my URL's. I have this .htaccess file saved in the root folder. It works perfectly on localhost but when I upload it to the server it doesn't work. The correct URL appears in the address bar but the page stays on homepage. Any tips?
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /
# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteCond %{THE_REQUEST} ^GET
RewriteRule ^index\.php(.+) $1 [R=301,L]
# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Make sure your AllowOverride Directive in Apache is configured to allow .htaccess files and your server has mod_rewrite installed and active.
On Mac OS X, you'll find this file at /etc/apache2/httpd.conf. Look for the <Directory> Directive and change it to be:
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
</Directory>
You'll need to restart Apache so it can read the new configuration:
sudo /usr/sbin/apachectl restart
If you'd prefer to use a GUI to restart Apache, go to Apple > System Preferences > Sharing and toggle the checkbox next to the Web Sharing service.
If you're using Windows or any flavor of Linux, the same approach applies, but the Apache configuration may be in a different place, especially if you're using WAMP or MAMP.
Also, for reference, the "officially supported method" by EllisLab for Removing index.php from ExpressionEngine URLs is the following:
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>