Forum Moderators: phranque
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
When I got to the home page is show redirect to example.com but doesn't.
Simple test to see if .htaccess is being recognized and mod_rewrite is working:
RewriteRule foobar\.html http://www.example.com/rewrittenurl.html [R=301,L]
Request foobar.html in your browser. If things are working, you will wind up on the 404 page, but your browser's address bar will say rewrittenurl.html
RewriteEngine on
RewriteRule test\.html http://www.example.com/rewrittenurl.html [R=301,L]
Is this possible in htaccess on shared hosting?
# BEGIN WordPress
#<IfModule mod_rewrite.c>
#RewriteEngine on
#Options FollowSymLinks
#RewriteBase /news/
#RewriteRule ^index\.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /news/index.php [L]
#</IfModule>
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) [webmasterworld.com...] [R=301,L]
From my httpd.conf
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
.htaccess file
Options +FollowSymLinks
DocumentRoot "C:/www/webroot"
<Directory />
Options +Indexes +FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
<Directory "C:/www/webroot">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
#Enable .htaccess
AccessFileName .htaccess
<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
DocumentRoot c:/www/webroot/example
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.example.com/$1 [R=301,L]
</VirtualHost>
For security and performance reasons, do not set AllowOverride to anything other than None in your <Directory /> block. Instead, find (or create) the <Directory> block that refers to the directory where you're actually planning to place a .htaccess file.
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
<Directory "C:/www/webroot">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "C:/www/webroot/intranet">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "C:/www/webroot/website1">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "C:/www/webroot/website2">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>