Currently I am using the hosting with lightspeed server. Hosting says mod_rewrite is enabled but I can't get my script working there. Whenever I try to access the URL, it returns 404 - not found page.
I put the same codes at another server which is running with Apache. It's working over there. So I guess, it's the .htaccess and mod_rewrite issue.
But Hosting support is still insisting with me that their mod_rewrite is on, so I would like to know how can I check whether it's actually enabled or not.
I tried to check with phpinfo(), but no luck, I can't find mod_rewrite there, is it because they are using lightspeed?
Is there any way to check? Please help me out. Thank you.
FYI: my .htaccess code is
Options -Indexes
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
I tried like this also
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
But same result.
from the command line, type
sudo a2enmod rewrite
if the rewrite mode is already enabled, it will tell you so!
To check if mod_rewrite module is enabled, create a new php file in your root folder of your WAMP server. Enter the following
phpinfo();
Access your created file from your browser.
CtrlF to open a search. Search for 'mod_rewrite'. If it is enabled you see it as 'Loaded Modules'
If not, open httpd.conf (Apache Config file) and look for the following line.
#LoadModule rewrite_module modules/mod_rewrite.so
Remove the pound ('#') sign at the start and save the this file.
Restart your apache server.
Access the same php file in your browser.
Search for 'mod_rewrite' again. You should be able to find it now.
If you are using a virtual hosts configuration file, make sure the virtual host in question has the directive AllowOverride All somewhere like this:
<VirtualHost *:80>
...
<Directory "directory/of/your/.htaccess">
AllowOverride All
</Directory>
</VirtualHost>
Basically, this states to allow processing of all .htaccess directives.
This works on CentOS:
$ sudo httpd -M |grep rewrite_module
Should output rewrite_module (shared)
console:
<VirtualHost *:80>
...
<Directory ...>
AllowOverride All
</Directory>
</VirtualHost>
sudo a2enmod rewrite
sudo service apache2 restart
If apache_get_modules() is not recognized or no info about this module in phpinfo(); try to test mod rewrite by adding those lines in your .htaccess file:
RewriteEngine On
RewriteRule ^.*$ mod_rewrite.php
And mod_rewrite.php:
<?php echo "Mod_rewrite is activated!"; ?>
PHP's perdefined apache_get_modules() function returns a list of enabled modules. To check if mod_rewrite is enabled , you can run the following script on your server :
<?php
print_r(apache_get_modules());
?>
If the above example fails, you can verify mod-rewrite using your .htaccess file.
Create an htaccess file in the document root and add the following rewriteRule :
RewriteEngine on
RewriteRule ^helloWorld/?$ /index.php [NC,L]
Now visit http://example.com/HelloWorld , You will be internally forwarded to /index.php page of your site. Otherwise, if mod-rewrite is disabled , you will get a 500 Internel server error.
Hope this helps.
If
in_array('mod_rewrite', apache_get_modules())
returns true then mod-rewrite is enabled.
you can do it on terminal, either:
apachectl -M
apache2ctl -M
taken from 2daygeek
If this code is in your .htaccess file (without the check for mod_rewrite.c)
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
and you can visit any page on your site with getting a 500 server error I think it's safe to say mod rewrite is switched on.
You can use php function
apache_get_modules
and check for mod_rewrite
<pre>
<?php
print_r(apache_get_modules());
?>
</pre>
http://in2.php.net/apache_get_modules
If you are in linux system, you can check all enable modules for apache2(in my case) in the following folder:/etc/apache2/mods-available
cd /etc/apache2/mods-available
to type: ll -a
if you want to check the available modules for php (in this case php 7 )
folder /etc/php/7.0/mods-available
cd /etc/php/7.0/mods-available
to type: ll -a
I know this question is old but if you can edit your Apache configuration file to AllowOverride All from AllowOverride None
<Directory "${SRVROOT}/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
just make a new page and add this code
<?php
if(!function_exists('apache_get_modules') ){ phpinfo(); exit; }
$res = 'Module Unavailable';
if(in_array('mod_rewrite',apache_get_modules()))
$res = 'Module Available';
?>
<html>
<head>
<title>A mod_rewrite availability check !</title></head>
<body>
<p><?php echo apache_get_version(),"</p><p>mod_rewrite $res"; ?></p>
</body>
</html>
and run this page then find will able to know module is Available or not if not then you can ask to your hosting or if you want to enable it in local machine then check this youtube step by step tutorial related to enable rewrite module in wamp apache
https://youtu.be/xIspOX9FuVU?t=1m43s
Wamp server icon -> Apache -> Apache Modules and check the rewrite module option
This code worked for me:
if (strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false) echo "mod_rewrite enabled";
else echo "mod_rewrite disabled";
First you check if the module is installed
apachectl -M
It it does not shows on the list, you must activate it:
a2enmod rewrite
Now, restart your server and test
systemctl restart apache2
You just need to check whether the file is there, by typing
cat /etc/apache2/mods-available/rewrite.load
The result line may not be commented starting with #
I was having the exact problem, I solved it by clicking custom structure, then adding /index.php/%postname%/ and it works
Hope this saves someone the stress that I went through finding what the heck was wrong with it.
Simply create a php file in root and add following code
<?php
if (in_array('mod_rewrite', apache_get_modules())) {
echo "mod_rewrite is enabled";
} else {
echo "mod_rewrite is not enabled";
}
Related
I have a rather strange issue with my website. I have just decided to remove my website from one server to a new server (I no longer wanted to use wpengine.co.uk)
I have now got the site up and running however the only issue I have is if I set the "permalinks" option to "post name" as can be seen here: http://i.imgur.com/poyRQ9x.png then I get a 404.
I have the following Apache setup on a Linux box:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
My .htaccess looks like this (for now I have set the file permissions to 666):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Lastly I have enabled as can be seen from my "phpinfo()" page.
The site does work if I use the ugly looking "plain" option... but that is obviously something I don't want.
Reboot Apache after making changes to httpd.config. (Changes to pph.ini and .htaccess don't require reboots).
And, you may need to add AllowOverride All for the document root:
<Directory /var/www/html>
# ... other directives...
AllowOverride All
</Directory>
Please remove your .htaccess file from wordpress root directory, then try to change permalink setting.
Note :- backup .htaccess file before delete it.
I hope this will work for you.
Well the answer turned out to be rather strange. It appears that for this to work I needed to install some extra PHP extensions. All I needed to do was:
sudo apt-get install php-mbstring php7.0-mbstring php-gettext
Although I think that the one that finally worked was:
sudo apt-get install php-curl
I saw warnings about this but I had no idea that that would actually stop WordPress's redirection. If somebody knows why this is the case I'd be really grateful to know.
I am trying to get mod_rewrite to work by using a .htaccess file on my localhost server.
My apache2.conf file contains:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
And:
Include mods-enabled/*.load
/etc/apache2/mods-enabled/rewrite.load file contains:
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
The .so file exists.
service apache2 restart shows no warnings/errors
My .htaccess contains:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /process.php?path=$1 [NC,L,QSA]
And it's located at /var/www/wp/wp-content/plugins/myplugin/
process.php contains print_r($_SERVER);
I am visiting http://localhost/wp/wp-content/plugins/myplugin/randomstring and always getting a 404 error.
I tried changing the .htaccess file to a random string trying to trigger a 500 error to make sure the .htaccess was being "executed"(?), but still getting a 404 not found error.
var_dump(in_array('mod_rewrite', apache_get_modules())); returns true
what am i doing wrong? This always works on my online servers.
Check if the module is enabled using php_info(). If there is some errors.
Try the following command.
sudo a2enmod rewrite
I think if you change (/etc/apache2/sites-available/default) AllowOverride none to AllowOverride All then it will work.
If still you are getting the error, then do the steps mentioned here.
The tutorial is bit old, but you can get the module working.
I hope this helps.
Very new to this stuff so please be gentle with me.
I'm running a server with Debian8, and using it to host my website, Teamspeak and a bit of file storage.
After moving my server files into /var/www/html and sorting out DNS-stuff my site is up and running - but the clean URL fix I used (with the .htaccess file) no longer functions. I wanted to find out if this was a mod_rewrite issue so I tried to check using a phpinfo.php file - which kept downloading in browser instead of executing.
My .htaccess file looks as follows:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
# Hide .html extension
## External Redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,NC]
## ## Internal Redirect
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html
AddHandler php5-script .php
Things I have done:
Installed PHP5.
apt-get -y install php5 libapache2-mod-php5
and then restarted Apache
service apache2 restart
I hoped this would fix the PHPInfo.php issue, but still no success, so I attempted to edit the .htaccess file using
AddHandler php5-script .php
I'm assuming this will work but my .htaccess file isn't functioning so I figured I need to sort that first.
I checked for Mod_rewrite using
a2enmod rewrite
and was informed the module was already enabled. Okay, not a mod_rewrite issue.
Further searching led me to find /etc/apache2/apache2.conf, where I changed
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to `
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>`
Still no dice! I also checked /etc/apache2/sites-available/ and found two files, 000-default.conf (which contains none of the above code) and default-ssl.conf (same situation). I also have /sites-enabled/ which for some reason just contains a shortcut to the previous 000-default.conf file.
I'm pretty much at my wits end now, I've Google'd this stuff to death and my poor knowledge of the workings of this stuff is clearly hindering my progress. Can anyone help?
I need some help with laravel 4 application i need to remove Index.php from url i have tried the solution that has been mentioned in laravel documentation
Pretty URLs
Apache
The framework ships with a public/.htaccess file that is used to allow URLs without index.php. If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.
If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
any Suggestions :) ?
FOR LAMP SERVER
Try the following steps,
Activate the mod_rewrite module with,
sudo a2enmod rewrite
and restart the apache
sudo service apache2 restart
To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with
sudo nano /etc/apache2/sites-available/000-default.conf
Search for “DocumentRoot /var/www/html” and add the following lines directly below:
<Directory "/var/www/html">`
AllowOverride All
</Directory>
Save and exit the nano editor via CTRL-X, “y” and ENTER.
Restart the server again:
sudo service apache2 restart
this worked for me
<Directory "/var/www/html">`
AllowOverride All
</Directory>
uncomment 'LoadModule rewrite_module modules/mod_rewrite.so' in apache httpd.conf
in 'public' folder check .htaccess file (created by default)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have read long posts and threads but nothing works then i found this and it works for me.
The easiest way to do this (and the way I always use) is to open up your Command prompt or Terminal and cd into the main directory of your project then run "php artisan serve". That's it. You're done. Don't believe me? Check out http://localhost:8000 and admire your Laravel work.
http://michaelbrooks.co.uk/post/laravel-localhost-removing-public-index-php
just go to your apache settings folder, i use wamp so myne is
C:/wamp/bin/apache/apache2.4.9/conf/httpd.conf - file
// located on line 154 precisely...
#LoadModule rewrite_module modules/mod_rewrite.so
// to
LoadModule rewrite_module modules/mod_rewrite.so
restart WAMP and BOOM!.. it works.
mod_rewrite apache module may not be enabled by default. enable it and retry.
Try this:
a2enmod rewrite
And it will works
I'm using opencart version 1.5.5.1 for our website.
When I enable seo in admin section the urls lead to 404.
My site url is https://www.domain.com/dev/.
The .htaccess file content is as follows:
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /dev/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
#RewriteRule ^(.*)\?*$ index.php?route=$1 [L,QSA]
### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
# 7. disable open_basedir limitations
# php_admin_value open_basedir none
I know this topic is already posted but the solutions provided didn't work for me.
Please help me. Thanks in advance!
Check this list for search some errors:
Renamed .htaccess.txt -> .htaccess
Enabled Mod_Rewrite on Apache2:a2enmod rewrite then service apache2 restart
Changed the apache2.conf file, located at /etc/apache2/ :
Where is
<Directory /var/www/your-store>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
You Change to
<Directory /var/www/your-store>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
First I don't think rewrite mod is enabled by default. enable it according to distro. for ubuntu - sudo a2enmod rewrite
Try to change AllowOverride none to AllowOverride All in /etc/apache2/sites-enabled/yousiteFile
Ubuntu and some distros work differently. second the default vhost has override set to none so that the htaccess is not allowed to rewrite anything.
restart apache.
Yes, AllowOverride All makes the SEO URL works for me.
As mentioned above, make sure to
sudo a2enmod rewrite
to enable rewrite on Apache.
Then make sure the RewriteEngine On is added to the domains in /etc/apache2/sites-available/
I have a solution for http 404 error. Even I faced a difficulties in starting but now it is very easy to solve it.
Login Opencart Admin .. then edit setting ..then in server section disable use SEO url. Then you will not get any error. Bye
Or if you don't want to disable url then follow below method.
Just edit .htaccess.txt to .htaccess.
You will get this file in root folder.