Tag Info

New answers tagged

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 ...


0

I'm not sure what behavior do you want, I see no mention of index.php in your request, but it is in your configuration. Anyway this rewrites any URL from the form hostname/XX to hostname/i.php?c=XX RewriteEngine On RewriteRule ^/([a-zA-Z]{2})$ /i.php?c=$1 [R=301,NC,L] For the opposite translation: RewriteCond %{QUERY_STRING} ^c=([a-zA-Z]{2})$ ...


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]


0

What you really need is to not use absolute links on your site, only relative links. (i.e. instead of having your pages with hardcoded URLs like http://www.mysite.com/foo/bar you'd have URLs like /foo/bar. You are asking to rewrite the content which apache doesn't do. However if I'm mistaken and you do use relative links - there's one thing you can ...


0

I believe you need to include Options +FollowSymLinks meaning your .htaccess should look something like below: Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ [NC] RewriteRule ^(.*)$ http://www-staging.mysite.com/$1 [L,R]


0

If you know the parant domain and want to block it and all of its sub-domains: ^https?://([^.]+\.)*exampledomain\.com


0

Yes. You could replace "http://(www\.)?" with ".*" as long as you don't expect that domain name to appear elsewhere in legitimate referer strings. I'd also suggest putting .* after the .com or .net in case any slashes or paths get tacked on there.


0

If they have access to do this on their computer, you might want to see if they can try a different web browser. If they don't have admin privileges and can't install one, but it's not against their policies to do so, they could run a "portable" / standalone one which doesn't require an install. Another workaround would be to add a "Satisfy any" line and ...


0

It's possible there is some Allow directive somewhere that is causing them to be granted access. Try enabling mod_info and pull up the mod_info page and do a case insensitive search for all instances of "allow" (no quotes) to see if there are any directives which could be doing this. http://httpd.apache.org/docs/2.2/mod/mod_info.html


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].


0

Yes, you can use RewriteCond to match any part of the domain you want in %{HTTP_HOST} and then reference it in your RewriteRule by using a %1 backreference (%# refers to matched items in parenthesis in the most-recently matched RewriteCond directive).


0

On shared hosting, when you don't have better options, you could modify your rewrite rule in the .htaccess: RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] First, the RegEx at the beginning matches to all requests, including everything behind the domain. Then, a HTTP Result code of 301 (moved permanently) is thrown back to the client together with ...


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 ...


0

You could use RewriteRule's [F] flag to deny the access to all but the permitted IP(s). See the following for an example (I didn't test this but I think it's correct). If you want to use the allow directive, Another way to do it is to use Rewrite directives to set an environment variable using the [E=...] flag of RewriteRule and then do Allow from ...


0

Location directive is not allowed in .htaccess file. Otherwise, you can add these lines in your Apache configuration file / virtual host file.


0

You can use RewriteCond to match the last part of the domain name and then in your RewriteRule immediately following that, utilize that match in your path by using a %1 reference (note the percent sign, not a dollar sign, which refers to the most recently matched RewriteCond).


0

I've just try your setup with a small change respect to your config. I am configuring it on the config file instead of .htaccess using this (note it searches for beggining with /topics -instead of topics-): RewriteRule ^/topics\/([-0-9a-zA-Z]+)?\/([0-9]+)(-)([0-9a-z,-]+)? http://example.net/topics/$1/$4 [L,R=301] Then the test works as expected: ...


0

I resolved it by my selfe: RewriteCond %{HTTP_HOST} ^(www\.)?ippservice\.kommt\-bald\.at$ RewriteRule ^(/)?$ service [R]


0

Have you checked the file system permissions? I would like to think that the default user account running apache should not have access to c:/.... http://httpd.apache.org/docs/2.4/howto/htaccess.html


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.


0

RewriteRules in .htaccess "ignore" all the preceding path elements: In Directory and htaccess context, the Pattern will initially be matched against the filesystem path, after removing the prefix that led the server to the current RewriteRule (e.g. "app1/index.html" or "index.html" depending on where the directives are defined). so you may want ...


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 ...


0

I think that this should work : RewriteRule ^(.*)$ $1? [R=301,L] As a result it gives me : site.com/gallery/var/resizes/somename/somename1/somename2.jpg


0

You need to change two parts: Rewrite rules in your .htaccess so that it recognizes the changed rules URL generation in your web application, so that it generates URLs the way you want. is definitely the harder part here.


0

A bit of "a stab" at it (read: not looking at the documentation right now), but it'd be: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.*)/?$ $1/index.php [QSA] That being said, your conditions already read "if request filename is not a directory and request filename is not a file, then rewrite as this rule." So, if ...


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

On "my site" the file is offered for download because of the content disposition header: Content-Disposition: attachment; filename="robots.txt" To not download the file but instead render it in the browser - all that's required is to remove that header. It's of no real consequence whether the file is served with or without that header, as the intended ...


0

I'm guessing that someone (or set of someones) is either scraping your site (badly), or has their page on refresh. You can work around this either by blocking their IP address, or, if you don't mind, just caching the page so it effectively costs your server nothing. You can do this through the use of "Cache-control:" header.


1

I would approach this by making a script that makes symlinks to all those files to the directory where you want the files to be visible. Then you could use something like lsyncd to monitor the directories and automatically generate symlinks whenever new files appear or existing files change.


1

First of all, if you have access to server configuration, you should not use .htaccess as it slows down your Apache. Also, it is much easier to handle this with two separated virtual hosts. 1) /etc/apache2/sites-enabled/000-default (for IP and non-specified hostnames): <VirtualHost *:80> DocumentRoot /var/www/html </VirtualHost> 2) ...



Top 50 recent answers are included