摘要:记录一下直接在服务器配置文件中做的一些配置
<rewrite>
<rules>
<rule name="Redirect 301 page2" stopProcessing="true">
<match url="^news-going-green-efforts-by-the-worldwide-multinationals-58.html" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="https://www.streetlights-solar.com" />
</rule>
</rules>
</rewrite>
<rule name="WWW Redirect" stopProcessing="true">
<match url="^(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.stanfordmagnets.com/{R:0}" redirectType="Permanent" />
</rule>
其中域名前面的^不能去掉或者换成http等,否则会不执行。rules和rewrite不能去掉否则会报错。
一般的如下写就行
<rewrite>
<rules>
<rule name="Redirect 301 page1" stopProcessing="true">
<match url="^aaa.html" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="http://www.baidu.com/" />
</rule>
</rules>
</rewrite>
######
注意这里<match url="^aaa.html" /> 最好按照正则规则<match url="^aaa.html$" />采用$结尾
######
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.samaterials.com$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
RewriteRule ^lab6/1411-lanthanum-hexaboride-lab6-rod.html$ http://www.samaterials.com/lab6/1657-lanthanum-hexaboride-lab6-rod.html [R=301,L]
RewriteRule ^manufacturers$ http://www.samaterials.com [R=301,L]
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="OrgPage" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(.*)$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
//TP 中使用
return array(
//'配置项'=>'配置值'
'DB_CHARSET'=> 'utf8', // 字符集
'DB_TYPE' => 'mysql',
'DB_HOST' => 'localhost',
'DB_NAME' => 'sputter_sputtertargets2',
'DB_USER' => 'sputter_sputter',
'DB_PWD' => 't+w!2p+A',
'DB_PORT' => '3306',
'DB_PREFIX' => 'sput_',
'MODULE_ALLOW_LIST' =>array('Home'), // 分组
'DEFAULT_MODULE' =>'Home', // 默认分组
'URL_MODEL' => 2, // URL模式
/*'APP_STATUS'=>'debug',
'APP_DEBUS'=>true,
'SHOW_PAGE_TRACE' =>true, // 显示页面Trace信息*/
'DATA_CACHE_SUBDIR'=>true, // 开启子目录缓存
'DATA_PATH_LEVEL'=>2, // 子目录层次 默认为1
'URL_CASE_INSENSITIVE' =>true, // URL不分大小写
'TMPL_CACHE_ON' => false, // 是否开启模板编译缓存,设为false则每次都会重新编译
'URL_HTML_SUFFIX'=>'html', // 设置伪静态
'SESSION_AUTO_START' =>true, //开启session
'URL_ROUTER_ON' => true, // 开启路由
'URL_ROUTE_RULES' => array( // 定义路由规则,美化url
'rss.xml'=>'Index/GetRssXml',
'verify' => 'Htmls/GetVerify',
'submit' =>'Htmls/inquiry_check',
'reclaim-service' => 'Htmls/Reclaim',
'inquiry' => 'Htmls/inquiry',
'glossary'=>'Index/GlossaryInfo',
'sitemap'=>'Index/sitemap',
'elements'=>'Products/ByElements',
'faq'=>'Index/FAQInfo',
'thankyou'=>'Htmls/ThankYou',
'searchresult'=>'Index/SearchProducts',
'sorry'=>'Common/DefaultHtml',
'popular/:name'=>'Index/GetSearch',
':slug/:products_slug' =>'Products/product_detail',
':slug' =>'Index/UrlRoute',
),
);
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".apk" />
<mimeMap fileExtension=".apk" mimeType="application/vnd.android" />
</staticContent>
<rewrite>
<rules>
<rule name="WWW Redirect" stopProcessing="true">
<match url="^(.*)" />