Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess特定的url更改_.htaccess_Mod Expires - Fatal编程技术网

.htaccess特定的url更改

.htaccess特定的url更改,.htaccess,mod-expires,.htaccess,Mod Expires,我对CMS系统中的.htaccess有一个小问题,但很难理解 我有mod expires,在整个网站上缓存东西,但我不想在/admin URL中缓存东西,我不能再做一个.htacess,因为我有MVC结构,没有真正的目录可以保存我所有的管理员东西 我已经找到了指令,但它只在服务器配置中工作,我希望它能在不同的主机上工作,所以只能在htaccess文件中工作 编辑-重写 # Turn on URL rewriting RewriteEngine On # Installation directo

我对CMS系统中的.htaccess有一个小问题,但很难理解

我有mod expires,在整个网站上缓存东西,但我不想在/admin URL中缓存东西,我不能再做一个.htacess,因为我有MVC结构,没有真正的目录可以保存我所有的管理员东西

我已经找到了指令,但它只在服务器配置中工作,我希望它能在不同的主机上工作,所以只能在htaccess文件中工作

编辑-重写

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ![0-9]$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
#启用URL重写
重新启动发动机
#安装目录
重写基/
重写cond%{HTTP_HOST}^www.[NC]
重写cond%{HTTP_HOST}![0-9]$[NC]
重写规则^(.*)$http://www.%{HTTP_HOST}/$1[L,R=301]
#保护隐藏文件不被查看
命令拒绝,允许
全盘否定
#保护应用程序和系统文件不被查看
重写规则^(?:应用程序|模块|系统)\b.*index.php/$0[L]
#允许直接显示现有的任何文件或目录
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#将所有其他URL重写为index.php/URL
重写规则。*index.php/$0[PT]

您可以使用带有表达式的
指令应用Expires指令,以与
/admin
匹配:

<If "%{REQUEST_URI} =~ /^\/admin\//">
    # Your expiry directives
</If>

#您的到期指令

如果您知道确切的URL,则可以尝试此模式

RewriteRule ^facebook/get/(.*)?$    http://$1 [NC,R]
RewriteRule ^wrapper/share/(.*)?$ http://example.com/wrapper/share/$1 [NC,R]
这将检查facebook/get/所在的URL,然后发送到

喜欢

RewriteRule ^stats/(.*)$ admin/dashboard.php?mode=openstats&event_id=$1 [NC,L,QSA]
**如果URL有stats/则它将重定向/打开admin/dashboard.php**

如果你的URL没有确切的值,但是你知道URL插槽模式,那么你可以试试这个

RewriteRule ^([^/.]+)/([a-zA-Z0-9_-]+)/$ wrapper/index.php?id=$2 [NC,L,QSA]

你应该更精确,比如你正在使用的CMS,没有“真实目录”的MVC是什么,等等。但是如果你正在使用.htaccess,你可以通过设置特定的规则来模拟目录行为,这些规则只适用于某些URL Syntaxit本地生产的CMS,在difrent real directrories中有很多复杂的从目录到管理的东西。我的问题是,如何模拟cerain URL语法的drectory行为。我想要所有的/admin/*url它还取决于您在.htaccess文件中已经拥有的内容(例如,url重写可能会弄乱一些路径指令)。应该可以使用
,您可以在其中添加适用于URL特定路径的指令。请参阅此处了解详细信息,如果您仍然有troubleDirectory,并且DirectoryMatch在htacess文件中不工作,我可以在今晚编写一个精确的答案。我会用重写来更新我的问题。对不起,那就是为什么我从来没有用过它:p如果之前没有回答,我今晚会检查一下。。也许是用fileMatch?它给了我一个错误500@Aksebkit您使用的是哪个版本的apache?