New answers tagged

1

This will return a 403 “Forbidden” response whenever any of these file extensions are requested from a site other than your own. RewriteRule \.(gif|jpe?g?|png|mp3|mp4|wmv|flv|avi)$ - [NC,F,L] You also need to add the site exception rule underneath the hotlinking rule. The .htacces file works in a cascading fashion just like a CSS file. So those (example....


2

There is indeed another setting that controls redirects. To make Apache look at .htaccess, it is necessary to change the AllowOverrides line in the apache .conf file for the site: <Directory /var/www/oldsite/> Options FollowSymLinks AllowOverride **None** Require all granted </Directory> You can replace None by All to enable ...


1

RewriteRule ^/contact/?view=full$ /contact/ [R=301,L] The RewriteRule pattern matches against the URL-path only, which notably excludes the query string. So, the above directive won't match the required URL. To match the query string you need to use an additional condition and check against the QUERY_STRING server variable. Also, in .htaccess (directory ...


1

you are still linking to the URL that contains /_? ... yes but whenever user tries to go to link onclick event ,in new tab he see the _/ in it Regardless of whether we implement a redirect in .htaccess to "fix" this, you do still need to physically remove the /_ part from the URLs in the HTML source that the users click on. Otherwise, they are not "hidden"...


4

You just need to implement your more specific redirect first, before your "generic" redirect everything else directive. For example: RewriteCond %{HTTP_HOST} example\.net$ [NC] RewriteRule ^en$ https://example.com/abc [L,R=301] RewriteCond %{HTTP_HOST} example\.net$ [NC] RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301] Aside... RewriteCond %{...


1

MyDomain1.example is my current domain and OtherDomain1.example is one of an external domain so Our Server that belongs to MyDomain1.example check if there is any request to OtherDomain1.example and do remaining... I still think I'm missing something here? It sounds like you are wanting to intercept and modify the request coming from your site MyDomain1....


2

Try the following at the top of your .htaccess file: RewriteRule (.*)-2/$ /$1/ [R=301,L] Any URL that ends in -2/ is redirected to the same URL without -2. The $1 (in the substitution string) is a backreference to the captured group (the part before the -2/) in the RewriteRule pattern.


2

I would say that exactly what you want to accomplish is not possible. Here is some useful information for you. First off: # and whatever comes after is never sent to the web server, and therefore .htaccess doesn't have access to read it. # is only used by the client (the web browser), whatever comes after it can be read by the browser and javascript however....


3

Try something like the following at the top of your .htaccess file to redirect the URL: RewriteEngine On RewriteRule ^feeds/\d+/comments/default /feeds/ [R=301,L] The pattern \d+ matches 1 or more digits. If the /comments/default part is not critical to make a match then it can be removed. If just matching a single digit is sufficient then change the regex ...


1

<IfModule mod_expires.c> ExpiresActive on </IfModule> That "bit" is entirely superfluous and can be removed. As you say, it looks like a "leftover". The important bit is that you already have ExpiresActive On in the previous code block, where it is being used.


1

From your directives, I assume your .htaccess file is located inside the /bb subdirectory. RewriteCond ^(fr|en|ar)/?(.*)?$ !-d RewriteRule ^en/?(.*)?$ ./$1?lang=English [L,QSA] RewriteRule ^fr/?(.*)?$ ./$1?lang=French [L,QSA] RewriteRule ^ar/?(.*)?$ ./$1?lang=Arabic [L,QSA] Whilst these directives might be "working perfectly", they are not "correct". ...


Top 50 recent answers are included