我有一个使用基本身份验证的.htaccess.似乎.htpasswd文件的路径与htaccess文件无关,而是与服务器配置相关.
因此即使我在同一目录中有.htaccess和.htpasswd文件,这也不起作用:
AuthType Basic
AuthName "Private Login"
AuthUserFile .htpasswd
Require valid-user
Run Code Online (Sandbox Code Playgroud)
但是,如果我将AuthUserFile更改为使用绝对路径,它确实有效:
AuthType Basic
AuthName "Private Login"
AuthUserFile "/home/user/public_html/mydir/.htpasswd"
Require valid-user
Run Code Online (Sandbox Code Playgroud)
但我更喜欢更具移动性的东西,因为我在不同领域的多个网站上使用它.我在网上搜索过但没有任何解决方案.是否可以使用相对路径或变量%{DOCUMENT_ROOT}?
我有一个文件夹,例如:/public_html/Davood/
和太多的子文件夹中的文件夹,例如:/public_html/Davood/Test1/,/public_html/Davood/Test1/Test/,/public_html/Davood/Test2/,...
我想添加一个htaccess文件到/public_html/Davood/拒绝DirectoryListing In /Davood和Sub文件夹,这可能吗?
我无法弄清楚为什么我的.htaccess标题设置不起作用.
我的.htaccess文件内容:
Header set Access-Control-Allow-Origin *
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Allow-Headers "*"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
Run Code Online (Sandbox Code Playgroud)
但是当我删除Header并添加它们时,index.php一切正常.
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: *");
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
为什么这样做:
RewriteRule (.+)/$ $1
Run Code Online (Sandbox Code Playgroud)
这项工作:
RewriteRule (.+)/$ $1 [L] #bla bla bla
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
RewriteRule (.+)/$ $1 #bla bla bla
Run Code Online (Sandbox Code Playgroud) 我试着把theese 2行
php_value post_max_size 30M
php_value upload_max_filesize 30M
Run Code Online (Sandbox Code Playgroud)
在我的根.htaccess文件,但这带来了"内部服务器错误"消息...
php5正在服务器上运行
我无法访问php.ini所以我认为htaccess是我唯一的机会.
你能告诉我哪里出错吗?
提前致谢
我有一个htaccess文件,它在主机上完美运行但是当我把它放在本地时,它显示我这个错误:
内部服务器错误
服务器遇到内部错误或配置错误,无法完成您的请求.
请联系服务器管理员admin @ localhost并告知他们错误发生的时间,以及可能导致错误的任何操作.
服务器错误日志中可能提供了有关此错误的更多信息.
我在错误日志文件中找到了此警报:
[Tue Apr 17 10:02:25 2012] [alert] [client 127.0.0.1] D:/wamp/www/jivan/sql/.htaccess:无效的命令'Header',可能拼写错误或由未包含在内的模块定义服务器配置
这是我的htaccess文件代码:
RewriteEngine On
AddDefaultCharset utf-8
RewriteRule ^([0-9-]+)/keyword_show.html$ keyword_show.php?keyword_id=$1
RewriteRule ^page_(.*).html$ page.php?url=$1
RewriteRule ^([0-9-]+)/(.*)/(.*)/(.*).html$ $2.php?advertisement_cat=$1&id=$3&pagenumber=$4
RewriteRule ^([0-9-]+)/(.*)/(.*).html$ $2.php?advertisement_cat=$1&pagenumber=$3
RewriteRule ^([0-9-]+)/(.*).html$ $2.php?advertisement_cat=$1
# cache images and flash content for one month
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# cache text, css, and javascript files for one month
<FilesMatch ".(js|css|pdf|txt)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
我的本地服务器由wamp运行,我也启用了重写模块!
那么问题是什么?!!
Google PageSpeed说我应该为JS和CSS"指定一个Vary:Accept-Encoding标头".我怎么在.htaccess中这样做?
我需要删除 index.php或public/index.php从Laravel生成的URL; 通常的道路是localhost/public/index.php/someWordForRoute,应该是这样的localhost/someWordForRoute.
的.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes.
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php[L]
Run Code Online (Sandbox Code Playgroud)
应用程序/配置/ app.php
'url' => 'http://localhost',
Run Code Online (Sandbox Code Playgroud)
我怎么能改变呢?
我的网站运行一个名为 - > WSS壁纸脚本的脚本
我的问题 - >我一直在尝试强制删除或在我的URL末尾添加尾部斜杠以防止重复内容并清理我的URL.
我已经尝试了各种各样的尝试,并尝试了我能想到的一切,并从互联网上加载,但没有这样的运气!这可能是一个快速修复,但我已经看了很多,我可能对死明显的东西视而不见.
所以我告诉你我所有的.htaccess代码:
DirectoryIndex index.php
RewriteEngine on
RewriteRule ^download/([0-9]+)?/([0-9]+)x([0-9]+)/([^/\.]+) image.php?id=$1&width=$2&height=$3&cropratio=$4&download=1 [L]
RewriteRule ^file/([0-9]+)?/([0-9]+)x([0-9]+)/([^/\.]+) image.php?id=$1&width=$2&height=$3&cropratio=$4 [L]
RewriteRule ^preview/([0-9]+)?/([0-9]+)x([0-9]+)/([^/\.]+) wallpaper_preview.php?id=$1&width=$2&height=$3&name=$4 [L]
RewriteRule ^thumbnail/([0-9]+)?/([0-9]+)x([0-9]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/]+) image.php?wallpaper_id=$1&width=$2&height=$3&cropratio=$4&align=$5&valign=$6&file=$7 [L]
RewriteRule ^cat/([0-9]+)?/([^/\.]+)/p([0-9]+) index.php?task=category&id=$1&name=$2&page=$3 [L]
RewriteRule ^cat/([0-9]+)?/([^/\.]+)/([0-9a-zA-Z?-]+)/p([0-9]+) index.php?task=category&id=$1&name=$2&sortby=$3&page=$4 [L]
RewriteRule ^cat/([0-9]+)?/([^/\.]+)/([0-9a-zA-Z?-]+)-([0-9]+) index.php?task=category&id=$1&sortby=$3&page=$4 [L]
RewriteRule ^cat/([0-9]+)?/([^/\.]+) index.php?task=category&id=$1&name=$2 [L]
RewriteRule ^tag/([^/\.]+)/([0-9a-zA-Z?-]+)/([0-9]+) index.php?task=tag&t=$1&sortby=$2&page=$3 [L]
RewriteRule ^tag/([^/\.]+) index.php?task=tag&t=$1 [L]
RewriteRule ^profile/([0-9]+)?/([^/\.]+) index.php?task=profile&id=$1&name=$2 [L]
RewriteRule ^profile/comments/([0-9]+)?/([^/\.]+) index.php?task=users_comments&id=$1&name=$2 [L]
RewriteRule ^page/([0-9]+) index.php?task=view_page&id=$1 [L]
RewriteRule ^register index.php?task=register [L]
RewriteRule ^lost-password index.php?task=lost_pass [L]
RewriteRule ^links index.php?task=links [L]
RewriteRule …Run Code Online (Sandbox Code Playgroud)