Tag Info

Hot answers tagged

5

You should configure Apache Virtualhosts to do the job. RewriteMod isn't the appropriate solution for this case and .htaccess isn't either. In your httpd.conf or equivalent use the following lines accordingly your needs. Edit it to your domain and site. NameVirtualHost *:80 <VirtualHost *:80> ServerName www.example.com example.com Redirect ...


1

You can simply use in .htaccess file: Redirect 301 /old/old.htm http://www.newdomen.com/new or Use RewriteEngine: RewriteEngine on RewriteBase / RewriteRule ^articles\/(.*)\.html$ $1 [R=301]


1

Unless an .htaccess file has been created before, you'll just need to create one in a relevant directory - for example, if you want a redirect from /foo/bar.html you can put the .htaccess file in the web root (/) or in the /foo directory. From there, you'll just want to use mod_alias for a simple redirect: Redirect /foo/bar.html ...


1

Try the block below, I just tested it myself on one of my Apache setups and it worked fine. <IfModule mod_rewrite.c> RewriteEngine on SetEnvIfNoCase User-Agent ^libwww-perl bad_bot Order Allow,Deny Allow from ALL Deny from env=bad_bot


1

Second argument to SetEnvIf is supposed to be regexp, so it should read as: SetEnvIf Request_URI ^/path/to/something.* access_granted your second attempt: SetEnvIf Request_URI "^/path/*" access_granted works because indeed you have 0 or more "/" symbols following /path In other words - you've attempted to use shell globs where regexp is expected.


1

I think for what you're trying to accomplish, I'd say "yes", but with the caveat if you wanted to be super technical, I think the directives match those filenames in any folder, but the RewriteRule as written is only in the current folder. Also, I think is case-sensitive but your rule is case-insensitive due to [NC].


1

Check if more specific configuration in userdir.conf overrides settings you specify in <Directory />. In /etc/apache2/mods-enabled/userdir.conf is specified Directory directive for userdir, default is: <IfModule mod_userdir.c> UserDir public_html UserDir disabled root <Directory /home/*/public_html> ...


1

The overall question is fairly broad, but I'll focus on your specific asks: Is it possible to have a directive for each directory in the httpd.conf? Yes, it is possible. Is the above better than placing .htaccess files in each application directory? They serve different purposes. <Directory> administratively defines ...



Only top voted, non community-wiki answers of a minimum length are eligible