.htaccess

htaccess Ignoring directory and its subdirectories

醉酒当歌 提交于 2020-01-07 05:10:10
问题 I have the following in my htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(mailinglist)/.*$ - [L] RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule> I basically want to remove htaccess from hitting that last line if I am in the mailinglist directory. This only works for items in the root of the /mailinglist directory. Once I go deeper like /mailinglist/w/1 it breaks and hits that last rewrite

how to prevent users having access to a particular directory

主宰稳场 提交于 2020-01-07 05:01:09
问题 I have a directory named "includes" containing information about my database and some other important files that users should not access. I want to use an .htaccess file to redirect requests that begin with "/includes" to errors/403.html . This is my code but it does not work. What's the problem?! RewriteEngine On # Turn on the rewriting engine RewriteRule ^/includes/([a-zA-Z]+)/?$ /errors/403.html [NC,L] 回答1: If your config files are php, you can just place empty index.php in that directory

Again stuck with HTACCESS

拈花ヽ惹草 提交于 2020-01-07 04:58:31
问题 What am I doing wrong here? It does not work for me :( Options +FollowSymLinks -MultiViews RewriteEngine on # use appropriate rewrite base RewriteBase /stage/customer/be/ RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$ RewriteRule ^ - [F] RewriteCond %{THE_REQUEST} /index\.php\?action=([\w-]+)&template_id=([\w-]+)&feedbackTypeID=([\w-]+) [NC] RewriteRule ^ %1/%2/%3? [L,R] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/?$ index.php?action=$1&template

Restrict directory for Friendly URLs .htaccess

僤鯓⒐⒋嵵緔 提交于 2020-01-07 04:58:09
问题 I want the site to be url friendly match, so that the directory / adm (which in my case is the administrative panel) has not url friendlies my .htaccess <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On </IfModule> # For all files not found in the file system, reroute the request to the # "index.php" front controller, keeping the query string intact <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L]

Redirect existing file to different url using mod_rewrite

安稳与你 提交于 2020-01-07 04:28:09
问题 I'm trying to use mod_rewrite to redirect an existing file to a different URL. I'm using the following and it has no effect. I've tried several variations of which don't work. RewriteEngine on AddHandler x-httpd-php .php3 # AddHandler x-httpd-php5 .php .php4 # This file exists, but this redirect doesn't work RewriteRule ^show.php?id=review-1$ /review/1/super-baseball-2020/ [R=301,L] Does it by chance have something to do with the url params? 回答1: You cannot have query string in RewriteRule.

.htaccess mod_rewrite remap without redirection?

雨燕双飞 提交于 2020-01-07 04:18:06
问题 I'm using the following to redirect http://example.com/somedir/?_escaped_fragment=key=val to http://example.com/somedir/static/?key=val. RewriteBase / RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$ RewriteRule ^(.*)$ - [E=BASE:%1] RewriteCond %{QUERY_STRING} ^_escaped_fragment=(.*)$ RewriteRule ^(.*)$ %{ENV:BASE}static/?%1 [L,R=302] How can I hide the URL change? I'd like to avoid using mod_proxy, if possible. 回答1: Simply remove the ,R=302 for an internal redirect, see: http://httpd.apache

Fastest way to redirect missing image files

烂漫一生 提交于 2020-01-07 04:12:25
问题 I have an on-the-fly thumbnailing system and am trying to find the best way to make sure it's as fast as possible when serving up images. Here is the current flow: User requests thumbnail thumbnails/this-is-the-image-name.gif?w=200&h=100&c=true htaccess file uses modrewrite to send requests from this folder to a PHP file PHP file checks file_exists() for the requested image based on the query string values If it does: header('content-type: image/jpeg'); echo file_get_contents($file_check_path

Apache's mod_rewrite failing to remove trailing slash

廉价感情. 提交于 2020-01-07 03:36:06
问题 I have a XAMPP Apache server, and have added a configuration file to rewrite URLs with a trailing slash and redirect to their slash-less counterparts. Therefore, a url like http://example.com/the-audio/ gets redirected to http://example.com/the-audio . The problem is, it's not working when the directory name is only one word. So, http://example.com/audio/ does not get it's slash removed. This is really strange for me, and checking the logs it appears as though the rule isn't matched in this

How to redirect https://sitename.com to https://www.sitename.com

浪子不回头ぞ 提交于 2020-01-07 03:00:41
问题 My redirect in htaccess file successfully redirects example.com to https://www.example.com but if I type: https://example.com in the address bar, I am not redirected. Current code looks a bit like this: RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^example.local$ RewriteCond %{SERVER_NAME} !.cms.me$ [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Adding the www after the https:// does not work: RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST

htaccess Mod_rewrite with accents

∥☆過路亽.° 提交于 2020-01-07 02:58:05
问题 I have an international website, and a section of the website, used to create a new person, has the person's name in the URL. I need that URL to allow accents as well as some special characters like à Right now I'm using: RewriteRule ^([áéíóúñÁÉÍÓÚÑäëïöüÄËÏÖÜçÇA-Za-z-]+)/?$ /newPerson.php?person=$1 [NC,QSA] UPDATE: This works, but is not a very elegant approach. I am asking for a better way of matching all letters (lower and uppercase) with all possible accents à, á, ä... etc, if there is