我有一个网站使用mod_rewrite来获取一些干净的url和自定义404页面。 我的.htaccess文件如下所示: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?clean_url=$1 [QSA,L] </IfModule> 让我感到困惑的是,如果URL包含%2F (url-encoded / ),服务器似乎强制一个404。例如, http://example.com/category/article将是一个正常的文章,但然后http://example.com/category%2farticle给出一个服务器生成的404页面。 (不是自定义404页面) 我不会期望这…这是为什么发生? 有没有办法解决它?
我使用.htaccess文件将网站redirect到另一个域。 现在我需要删除redirect,我已经删除了.htaccess文件,但对网站的请求仍然redirect。 我已经重新启动Apache,但没有运气。 .htaccess文件内容是否caching,或者有什么我在这里失踪? .htaccess的内容如下: Redirect 301 / http://www.example.com/ 谢谢
htaccess的: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php RewriteRule ^site-css/([0-9]+)/(.*)$ ../application/site/$1/design/css/$2 [L] 它返回一个400错误的请求,或者在apache级别: [Thu Jul 22 14:48:32 2010] [error] [client 127.0.0.1] Invalid URI in request GET /site-css/1/layout.css? HTTP/1.1 如果我更改规则,甚至稍微改变一个404错误。 有没有更多的方法来debugging这个问题?
我是一个mod_rewrite新手和正则expression式noob,但这是我想要做的: 我有一个脚本 ,将在飞行中重新调整图像的大小。 我希望能够采取任何图像文件path,添加一个查询string,并自动发送到脚本进行处理。 所以像这样: from: http://mysite.com/images/logo.jpg?w=100&h=50 to: http://mysite.com/images/thumbs/phpThumb.php?src=logo.jpg&w=100&h=50 当然,如果没有指定查询string,它应该指向原始文件。 使用/ images中的.htaccess文件,我已经得到了这个。 但它根本不起作用。 或者至多,它打破了我所有的网站图像: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{QUERY_STRING} ^.* RewriteRule ([^\s]+(\.(?i)(jpg|png|gif|bmp))$) /thumbs/phpThumb.php?src=$1 [L,QSA] </IfModule>
我的网站“受到攻击”:来自许多不同IP的漫游器正在填充垃圾内容的表单。 IP地址不能过滤,它们总是不同的,所以我想按照QUERY_STRING进行过滤,来匹配这样一个URI: www.site.com/search?field1=spamword&field2=another_spamword 规则 : rewritecond %{QUERY_STRING} ^(.*)spamword(.*)$ rewriterule .* – [F,L] 正则expression式看起来是正确的,但规则永远不会执行。 任何想法发生了什么? 谢谢。
请帮我写下nginx重写,而不是Apache htaccess: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)([^/])$ $1$2/ [R,L] RewriteCond %{ENV:REDIRECT_RDR} ^$ RewriteCond %{HTTP_HOST} ^(.+)\.site\.com$ #RewriteCond %2 !www RewriteCond %{HTTP_HOST} !^www\.site\.com$ RewriteRule ^([a-zA-Z0-9`~!@#$%^&()\-+";=\\/|]*)$ blogs/fake/%2/$1 [L,E=RDR:1] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !/urlrewriteprepend.php$ RewriteRule ^(.*)$ /urlrewriteprepend.php [L]
这是我的.htaccess文件的内容: php_flag allow_url_fopen on DirectoryIndex index.php <ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript </ifmodule> <IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|php|js)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule> <IfModule mod_expires.c> ExpiresActive On ExpiresDefault A86400 ExpiresByType image/png A2419200 ExpiresByType image/jpg A2419200 […]
我在MAMP堆栈上运行Drupal时遇到了一个不寻常的访问问题。 Drupal安装工作正常,所以我知道这不是一个Drupal的问题。 “干净的url”工作正常的单层url的任何事情,但没有2+path水平。 例如: example.com/foo,example.com/bar等。所有的工作都很完美。 example.com/foo/bar,example.com/bar/foo/bar等。不要工作。 我得到一个拒绝(不404)页面,由Drupal服务,与login框和网站名称,但没有主题应用。 (和,是的,我积极login作为pipe理员/用户1);) 如果我禁用“干净的url”,一切正常。 我认为这与我的htaccess中的重写规则有关,但searchnetworking无济于事(包括drupal的网站和irc频道)。 我当前的.htaccess如下所示: # # Apache/PHP/Drupal settings: # # Protect files and directories from prying eyes. <FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$"> Order allow,deny </FilesMatch> # Don't show directory listings for URLs which map to a directory. Options -Indexes # Follow symbolic links in this directory. Options +FollowSymLinks # Make Drupal […]
我需要通过cron调用一个php脚本。 cron条目将使用wget。 当我尝试从命令行调用脚本时,我得到“需要授权”,显然来自我的htaccess文件。 有谁知道我可以重写单个目录的htaccess文件?
我正在升级一个网站,我用这个.htaccess文件来显示维护页面: #MAINTENANCE-PAGE REDIRECT RewriteEngine on RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.0 # Bogus IP address for posting here RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.0 # Bogus IP address for posting here RewriteCond %{REQUEST_URI} !^/maintenance\.html$ RewriteRule ^(.*)$ http://www.mysite.no/maintenance.html [R=307,L] 这将打开所有用户的维护页面,除了我添加的两个IP地址。 他们得到一个Internal Server Error 。 我在另一个网站上使用了相同的脚本,并且工作正常。 看看错误日志,我看到以下内容: /var/www/vhosts/mysite.no/httpdocs/.htaccess: RewriteCond: bad flag delimiters 如果我删除我的.htaccess文件,我可以使用我的网站就好了。 我的网站使用CentOS 5托pipe在VPN上。 我该如何解决这个问题?