Test for .htaccess rewrites failed - apache

I am trying to install SugarCRM Enterprise 7.2 and I keep getting this error during system check:
Test for .htaccess rewrites failed. This usually means you do not have
AllowOverride set up for Sugar directory.
I am running Ubuntu 14.04 with LAMP, and I am trying to install Sugar to the local path
var/www/html/sugar_ent_7
I have already tried putting both
<Directory /var/www/ >
Allowoverride All
Order allow,deny
Allow from all
</Directory>
and
<Directory /var/www/html/sugar_ent_7 >
Allowoverride All
Order allow,deny
Allow from all
</Directory>
to my
/etc/apache2/apache2.conf
file, and no results. I have also tried making a
/etc/apache2/sites-available/sugar_ent_7.conf
file with this code
<Directory /var/www/html/sugar_ent_7>
Order allow,deny
Allow from All
AllowOverride All
</Directory>
and still nothing. What am I doing wrong?

Run the command
a2enmod rewrite;
in your terminal and restart your apache.
Hope this helps.

I met the same problem.
its aim is just to check the following code exists in your .htaccess:
# install/installSystemCheck.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase {$basePath}
RewriteRule ^itest.txt$ install_test.txt [N,QSA]
</IfModule>
I don't think SugarCRM is enough to check this setting, so let's just comment it out and make it passed:
#
// if($res != "SUCCESS") {
if(false) {
....

This error can also (misleadingly?) occur when sugar tries to address itself vi IP during the system check. When vhosting is configured it cannot find itself via IP, thus an entry to the hosts file can solve this. In the terminal enter:
vi /etc/hosts
Then add the IP of the system Sugar is running on with the URL you're referring to it, e.g.:
123.234.123.234 subdomain.host.com

# BEGIN SUGARCRM RESTRICTIONS
RedirectMatch 403 (?i).*\.log$
RedirectMatch 403 (?i)/+not_imported_.*\.txt
RedirectMatch 403 (?i)/+(soap|cache|xtemplate|data|examples|include|log4php|metadata|modules)/+.*\.(php|tpl)
RedirectMatch 403 (?i)/+emailmandelivery\.php
RedirectMatch 403 (?i)/+upload
RedirectMatch 403 (?i)/+custom/+blowfish
RedirectMatch 403 (?i)/+cache/+diagnostic
RedirectMatch 403 (?i)/+files\.md5$
# END SUGARCRM RESTRICTIONS
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /dir
RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&module=app_strings&lang=$1 [L,QSA]
RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&module=$1&lang=$2 [L,QSA]
</IfModule>
<FilesMatch "\.(jpg|png|gif|js|css|ico)$">
<IfModule mod_headers.c>
Header set ETag ""
Header set Cache-Control "max-age=2592000"
Header set Expires "01 Jan 2112 00:00:00 GMT"
</IfModule>
</FilesMatch>
<IfModule mod_expires.c>
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>

Related

Excluding a specific URL from HTTP Basic Auth - mod_rewrite causing problems

We have "HTTP Basic Auth" on a certain subdomain of ours, but would like to allow everything to access a specific URL on that subdomain without authenticating (for a 3rd party hitting our webhook URL).
So I tried to use SetEnvIf Request_URI ^/webhook/ allow to allow with Allow from env=allow (full file below) but it seems that because we've got some mod_rewrite rules to rewrite all these URLs to a PHP entry point, the Request_URI is never actually /webhook once it gets to this point (guessing but didn't know how to 100% confirm this.
It's still asking for a basic auth user/pass regardless of the URL.
Note that the .htaccess file is the same on all our domains / subdomains, whereas the VirtualHost can be configured just for this subdomain.
Full VirtualHost config with the "HTTP Basic Auth" config section:
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=permanent,L]
DocumentRoot /var/www/sub.ourdomain.co.uk/blah/www
ServerAdmin x#ourdomain.co.uk
ServerName sub.ourdomain.co.uk
ServerAlias www.sub.ourdomain.co.uk
ErrorDocument 400 /error.php
ErrorDocument 401 /error.php
ErrorDocument 403 /403.html
ErrorDocument 404 /error.php
ErrorDocument 405 /error.php
ErrorDocument 408 /error.php
ErrorDocument 410 /error.php
ErrorDocument 411 /error.php
ErrorDocument 412 /error.php
ErrorDocument 413 /error.php
ErrorDocument 414 /error.php
ErrorDocument 415 /error.php
ErrorDocument 500 /error.php
ErrorDocument 501 /error.php
ErrorDocument 502 /error.php
ErrorDocument 503 /error.php
ErrorDocument 506 /error.php
ErrorLog /var/log/httpd/sub.ourdomain.co.uk.apache.log
CustomLog /var/log/httpd/sub.ourdomain.co.uk.access.log combined
<Directory "/var/www/sub.ourdomain.co.uk/blah/www">
SetEnvIf Request_URI ^/webhook/ allow
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/httpd/passwords/sub.ourdomain.co.uk
# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "allow" var is set
Allow from env=allow
</Directory>
</VirtualHost>
.htaccess mod_rewrite rules:
RewriteCond %{REQUEST_METHOD} !(^GET|^POST|^HEAD)
RewriteRule .* - [R=405,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/img|/js|/css|/fonts)
RewriteRule ^(.*)$ /boot.php
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /boot.php
Edit 1 - based on the comments I also tried: SetEnv allow true and SetEnv allow 1 to remove the doubt of whether it's the URL and it still asks for the basic auth password, so it may not be related to the URL afterall.
Edit 2 - Adding the entire .htaccess to make sure I'm not missing something else:
php_value max_input_vars 4000
RewriteEngine on
# Disallow other HTTP verbs such as PUT and DELETE
RewriteCond %{REQUEST_METHOD} !(^GET|^POST|^HEAD)
RewriteRule .* - [R=405,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/img|/js|/css|/fonts|/twig|/pdf|/vendors|/server-status)
RewriteRule ^(.*)$ /boot.php
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /boot.php
AddType font/ttf .ttf
AddType font/eot .eot
AddType font/otf .otf
AddType font/woff .woff
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css text/javascript application/x-javascript application/javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json font/woff font/otf font/eot font/ttf
</IfModule>
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType font/ttf "access plus 604800 seconds"
ExpiresByType font/eot "access plus 604800 seconds"
ExpiresByType font/otf "access plus 604800 seconds"
ExpiresByType font/woff "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
</ifModule>
<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public, proxy-revalidate"
</filesMatch>
<filesMatch "\\.(js|css|ttf|eot|otf|woff)$">
Header set Cache-Control "max-age=604800, public, proxy-revalidate"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=216000, public, must-revalidate"
</filesMatch>
</ifModule>
Edit 3 - Sorry, should have mentioned that we're stuck on Apache 2.2 for now.
Using Apache 2.4+ you can use <If> expression to disable auth or use allow from all directive for a URI using THE_REQUEST variable. THE_REQUEST represents original request sent to Apache and it doesn't get updated in the context of a single request:
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/httpd/passwords/sub.ourdomain.co.uk
Require valid-user
Satisfy any
Order deny,allow
Deny from all
<If "%{THE_REQUEST} =~ /webhook/">
Satisfy any
Allow from all
</If>
# your current mod_rewrite rules can appear below this line:
DirectoryIndex boot.php
RewriteEngine on
# Disallow other HTTP verbs such as PUT and DELETE
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)
RewriteRule ^ - [R=405,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/img|/js|/css|/fonts|/twig|/pdf|/vendors|/server-status)
RewriteRule ^ boot.php [L]
Update: Here is a workaround solution that works on Apache 2.2 using <FilesMatch> directive:
DirectoryIndex boot.php
RewriteEngine on
# Disallow other HTTP verbs such as PUT and DELETE
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)
RewriteRule ^ - [R=405,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/img|/js|/css|/fonts|/twig|/pdf|/vendors|/server-status)
RewriteRule ^ boot.php [L]
SetEnvIfNoCase Request_URI ^/webhook/ allow
<FilesMatch "^(?!boot\.php$).*$">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/httpd/passwords/sub.ourdomain.co.uk
Require valid-user
Order Deny,Allow
Deny from all
Allow from env=allow
Satisfy any
</FilesMatch>

ProcessMaker on Centos 7 doesn't find mod_rewrite

I'm having trouble getting ProcessMaker running on CentOS 7. I've got through the CentOS 7 installation and have all of the prerequisites. I've modified my virtual hosts file to look like this:
NameVirtualHost my.host.com
<VirtualHost my.host.com:80>
ServerName my.host.com
DocumentRoot /opt/processmaker/workflow/public_html
DirectoryIndex index.html index.php
<Directory /opt/processmaker/workflow/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride none
Order allow,deny
Require all granted
Allow from all
ExpiresActive On
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*/(.*)$ app.php [QSA,L,NC]
</Directory>
</VirtualHost>
I receive the following error message:
Sistem Configuration Error:
Please review your apache virtual host configuration file, and be sure you have the following rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
I've verified that mod_rewrite is installed and loaded:
# ls /etc/httpd/modules | grep mod_rewrite
mod_rewrite.so
# grep rewrite /etc/httpd/conf.modules.d/00-base.conf
LoadModule rewrite_module modules/mod_rewrite.so
What am I missing here?
<VirtualHost *:9999>
ServerName 127.0.0.1
DocumentRoot /opt/processmaker/workflow/public_html
DirectoryIndex index.html index.php
<Directory /opt/processmaker/workflow>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
ExpiresActive On
ExpiresDefault "access plus 1 day"
ExpiresByType image/gif "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
ExpiresByType image/jpg "access plus 1 day"
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/javascript "access plus 1 day"
</Directory>
</VirtualHost>
I still don't understand why this was happening, but reinstalling everything slightly differently fixed it. The major change was using the default PHP installation, but adding the current EPEL repository to get php_mcrypt, but otherwise following the stock installation instructions. I don't see any good reason why this would have changed anything, but it now works.

Why are mod_expires and mod_headers not working on my server?

I've checked my plesk control panel on my vps and those mods are installed but when I run the site through http://redbot.org/ to check what's being sent, I get:
This response is negotiated, but doesn't have an appropriate Vary header.
The max-age Cache-Control directive appears more than once.
Cache-Control: no-cache, max-age=0, must-revalidate, no-transform, max-age=300
So it doesn't look like it's working.
Here's the .htaccess that I edited:
### SILVERSTRIPE START ###
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
<Files web.config>
Order deny,allow
Deny from all
</Files>
# This denies access to all yml files, since developers might include sensitive
# information in them. See the docs for work-arounds to serve some yaml files
<Files *.yml>
Order allow,deny
Deny from all
</Files>
# Define some expiry header settings.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 5 minutes"
ExpiresByType image/gif "access plus 7 day"
ExpiresByType image/png "access plus 7 day"
ExpiresByType image/jpg "access plus 7 day"
ExpiresByType image/jpeg "access plus 7 day"
ExpiresByType image/ico "access plus 7 day"
ExpiresByType text/css "access plus 7 day"
ExpiresByType text/javascript "access plus 7 day"
ExpiresByType application/x-javascript "access plus 7 day"
</IfModule>
# Append the 'Vary: Accept-Encoding' for resources that might need it.
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase '/'
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.php$
RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>
### SILVERSTRIPE END ###
I'm just trying to add a little client-side caching to my site and I was also advised to add the old Vary:Accept-Encoding for clients that can't handle gzip - apparently it's best practice to.
Any ideas where I'm going wrong here?
Your htaccess file has
<IfModule mod_expires.c>
It may be that your VPS doesn't have the mod_expires installed for apache. If that is the case then it would make sense that the expires configuration wouldn't get applied.
You can login as root to your server and run something like the 2 lines below (which might be a bit different depending on your server's config, apache version etc)
a2enmod expires
a2enmod headers
Then simply restart your Apache server:
systemctl restart apache2
or
service httpd restart
The above example works on Ubuntu 20.04 Server, running Virtualmin as a hosting solution. (tested myself)
For other installations, apache versions simply google: "a2enmod expires" on CentOS 7, Apache version 1

/index/ doesn't pull 404 looks similar to index.php but doesn't show css

I do not have a /index/ folder yet if I visit myname.com/index/ it pulls up the data on index.php but doesn't display the css because /index/style.css doesn't exist. I have tested this with many directory urls that do not exist, it's all the same thing.
/about/ pulls up the about.php page
/contact/ pulls up the contact.php page
only will a 404 occur when I try to load a url where a matching .php page doesn't exist.
Example: /blablabla/ returns a 404 because blablabla.php doesn't exist.
How do I make it so that /about/ /contact/ /index/ and other directories that have a matching .php file return a 404?
Here is a copy of my config file in /etc/apache2/sites-available
<VirtualHost *:80>
ServerAdmin webmaster#yourname.com
ServerName yourname.com
ServerAlias www.yourname.com
DocumentRoot /var/www/yourname.com/public_html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/yourname.com/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /var/www/yourname.com/public_html/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
LogLevel warn
ErrorLog /var/www/yourname.com/logs/error.log
CustomLog /var/www/yourname.com/logs/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/js "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType text/html "access 1 day"
ExpiresDefault "access 7 days"
</IfModule>
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 year (forever?)
<filesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</filesMatch>
# Set up caching on media files for 1 week
<filesMatch "\.(gif|jpg|jpeg|png|swf)$">
ExpiresDefault A604800
Header append Cache-Control "public"
</filesMatch>
# Set up 2 Hour caching on commonly updated files
<filesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "proxy-revalidate"
</filesMatch>
# Force no caching for dynamic files
<filesMatch "\.(php|cgi|pl|htm)$">
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</filesMatch>
# 480 weeks
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</filesMatch>
# 2 DAYS
<filesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>
# 2 HOURS
<filesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</filesMatch>
</VirtualHost>
Here is a copy of the .htaccess file in /var/www/yourname.com/public_html
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /var/www/yourname.com/.htpasswd
AuthGroupFile /dev/null
<Files admin.php>
require valid-user
</Files>
<Files systeminfo.php>
require valid-user
</Files>
There's really nothing in my .htaccess that I think would be causing this problem. Basically I am just password protecting two files located on the parent directory.
It's doing that because you've turned Multiviews on.
A MultiViews search is enabled by the MultiViews Options. If the server receives a request for /some/dir/foo and /some/dir/foo does not exist, then the server reads the directory looking for all files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements, and returns that document.
Try changing the line:
Options Indexes FollowSymLinks MultiViews
to:
Options Indexes FollowSymLinks -MultiViews
Or just remove the MultiViews option altogether. Unless there's some reason you have it turned on?

How to redirect my deleted links

i have my site where in pas i have a article directory but now i have deleted that article directory and google webmaster is shoing those links as not found and its a negative impact on my search results.
pls help me to redirect all links like this
http://www.mydomain.com/article/arts-entertainment/bradley-spalter-songs-getting-past-emotionally-charged-barriers/
to
http://www.mydomain.com
Current .htaccess file:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 day"
ExpiresByType text/plain "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 month"
ExpiresDefault "access 15 days"
</IfModule>
## EXPIRES CACHING ##
Options -MultiViews -Indexes +FollowSymlinks
RewriteCond %{http_host} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,NC]
RewriteRule ^golmagico/(.*)$ en/index.php?title=$1 [PT,L,QSA]
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
ErrorDocument 401 /default_error.php
ErrorDocument 402 /default_error.php
ErrorDocument 403 /default_error.php
ErrorDocument 404 /default_error.php
<IfModule mod_php5.c>
php_value register_globals 0
php_value magic_quotes_gpc 0
php_value session.auto_start 0
php_value safe_mode 0
</IfModule>
<IfModule sapi_apache2.c>
php_value register_globals 0
php_value magic_quotes_gpc 0
php_value session.auto_start 0
php_value safe_mode 0
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^detailed/recent/?([^/\.]+)?/?$ video.php?category=recent&page=$1&viewtype=detailed
RewriteRule ^detailed/viewed/?([^/\.]+)?/?$ video.php?category=viewed&page=$1&viewtype=detailed
RewriteRule ^detailed/recentviewed/?([^/\.]+)?/?$ video.php?category=recentviewed&page=$1&viewtype=detailed
RewriteRule ^detailed/discussed/?([^/\.]+)?/?$ video.php?category=discussed&page=$1&viewtype=detailed
RewriteRule ^detailed/favorites/?([^/\.]+)?/?$ video.php?category=favorites&page=$1&viewtype=detailed
RewriteRule ^detailed/rated/?([^/\.]+)?/?$ video.php?category=rated&page=$1&viewtype=detailed
RewriteRule ^detailed/featured/?([^/\.]+)?/?$ video.php?category=featured&page=$1&viewtype=detailed
RewriteRule ^detailed/random/?([^/\.]+)?/?$ video.php?category=random&page=$1&viewtype=detailed
RewriteRule ^recentviewed/?([^/\.]+)?/?$ video.php?category=recentviewed&page=$1
RewriteRule ^videos/?([^/\.]+)?/?$ video.php?category=recent&page=$1
RewriteRule ^recent/?([^/\.]+)?/?$ video.php?category=recent&page=$1
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/x-javascript text/css text/html text/xml
</IfModule>
Try putting this in your .htaccess
ErrorDocument 404 http://www.mydomain.com
it'll redirect all 404's to your domain.
or you can try:
RewriteRule ^articles/.*?$ / [NC]
to redirect all requests to the articles folder to root
Enable mod_rewrite
Enable .htacccess
Create a .htaccess file under DOCUMENT_ROOT
and place this code in there:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^article/ / [NC,L,R=301]
R=301 will tell Google and other search bots that all the links starting with /article/ have permanently moved to / (home page) and you will not have any negative impact on your rankings.