2014-04-17 58 views
0

這是我的網站URL http://sitename/search?city=1,我想在這個網址添加標題。 應該像http://sitename/search?city=1/titlehttp://sitename/title/search?city=1Yii - 在URL中添加標題。

所以我嘗試這樣的事情,

array(
    'search/<title>'=>'search', 
    '<title>/search'=>'search', 
) 

兩者都不能正常工作,無論是可以實現的,如果是的話如何實現這一目標?

+0

'http:// sitename/search?cit y = 1/title'將不起作用。 'http:// sitename/search?city = 1&title = title'是什麼?你需要路徑格式嗎? – Dinistro

+0

鏈接應該是可讀的,它傳達了一些信息和此站點名/ /搜索喜歡的東西?城市= 1,我用標題慣於處理任何事情,所以沒必要這樣與標題=標題... – <span class="text-secondary"> <small> <span></span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">你使用的URL規則之前打個電話試了這個?如果是的話,可以請你將它們添加 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/2903341/">Dinistro</a></span> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> </div> <div class="answer-title"> <span class="text-logo margin-top-sm">A</span> <h2 class="title h4">回答</h2> </div> <div class="item-description text-md markdown-body margin-bottom-40 voidso"> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">0<i class="fa fa-thumbs-up"></i></span> </div> <div class="post-offset"> <div class="answer fmt"> <p>結帳這篇文章,它介紹瞭如何使用您的網址的毛坯:</p> <p><a href="http://www.joshuawinn.com/yii-clean-seo-friendly-urls-for-pages/" rel="nofollow">http://www.joshuawinn.com/yii-clean-seo-friendly-urls-for-pages/</a></p> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/23127314">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2014-04-17 07:40:07</span> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/2329962/">Michiel</a></span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> </div> </article> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1038284119" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">0<i class="fa fa-thumbs-up"></i></span> </div> <div class="post-offset"> <div class="answer fmt"> <p>我finaly找到了解決辦法:</p> <pre><code class="prettyprint-override">array( '<action:\w+>/<title>/'=>'site/<action>' ) </code></pre> <p>,如果你有這個在您的<code class="prettyprint-override">rules</code>,您可以創建像這樣的網址:</p> <pre><code class="prettyprint-override">Yii::app()->createUrl("site/index", array('title' => 'test')); </code></pre> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/23127514">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2014-04-17 07:50:38</span> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/2903341/">Dinistro</a></span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> </div> </article> </div> <div class="clearfix"> </div> <div class="relative-box"> <div class="relative">相關問題</div> <ul class="relative_list"> <li> 1. <a href="http://hk.uwenku.com/question/p-sbkgpuio-bn.html" target="_blank" title="Yii:向標題添加JavaScript"> Yii:向標題添加JavaScript </a> </li> <li> 2. <a href="http://hk.uwenku.com/question/p-eatzfnbu-hn.html" target="_blank" title="如何在Yii中添加外部URL"> 如何在Yii中添加外部URL </a> </li> <li> 3. <a href="http://hk.uwenku.com/question/p-khtkwtnn-up.html" target="_blank" title="在PHP中添加標題"> 在PHP中添加標題 </a> </li> <li> 4. <a href="http://hk.uwenku.com/question/p-kphyqqlg-bbd.html" target="_blank" title="在godoc中添加標題"> 在godoc中添加標題 </a> </li> <li> 5. <a href="http://hk.uwenku.com/question/p-ykgzsmll-bob.html" target="_blank" title="將URL添加到Photoswipe圖像標題"> 將URL添加到Photoswipe圖像標題 </a> </li> <li> 6. <a href="http://hk.uwenku.com/question/p-gwwhxpoo-bkd.html" target="_blank" title="如何在yii url中添加其他變量"> 如何在yii url中添加其他變量 </a> </li> <li> 7. <a href="http://hk.uwenku.com/question/p-yvasnpkz-gy.html" target="_blank" title="向ASP.NET MVC中的URL slugs添加標識和標題"> 向ASP.NET MVC中的URL slugs添加標識和標題 </a> </li> <li> 8. <a href="http://hk.uwenku.com/question/p-ocpcfhnc-bhr.html" target="_blank" title="在網站標題中添加徽標"> 在網站標題中添加徽標 </a> </li> <li> 9. <a href="http://hk.uwenku.com/question/p-hhuvcrit-nh.html" target="_blank" title="在標題中添加圖標"> 在標題中添加圖標 </a> </li> <li> 10. <a href="http://hk.uwenku.com/question/p-awzpmpml-kd.html" target="_blank" title="在UICollectionViewController標題上添加UISearchBar標題"> 在UICollectionViewController標題上添加UISearchBar標題 </a> </li> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6208739752673518" data-ad-slot="4606349252"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <li> 11. <a href="http://hk.uwenku.com/question/p-uyqtcyvz-qm.html" target="_blank" title="添加CbuttonColumn到Csv標題列數組(在CgridView中使用) - Yii Framework"> 添加CbuttonColumn到Csv標題列數組(在CgridView中使用) - Yii Framework </a> </li> <li> 12. <a href="http://hk.uwenku.com/question/p-mrcbgpjm-bw.html" target="_blank" title="添加標題"> 添加標題 </a> </li> <li> 13. <a href="http://hk.uwenku.com/question/p-ypauizzq-bmp.html" target="_blank" title="Yii搜索標準並添加參數"> Yii搜索標準並添加參數 </a> </li> <li> 14. <a href="http://hk.uwenku.com/question/p-mquchwhx-baw.html" target="_blank" title="將屬性標籤添加到DynamicModel Yii"> 將屬性標籤添加到DynamicModel Yii </a> </li> <li> 15. <a href="http://hk.uwenku.com/question/p-pegzzzes-bcy.html" target="_blank" title="Yii的ajaxSubmitButton URL問題"> Yii的ajaxSubmitButton URL問題 </a> </li> <li> 16. <a href="http://hk.uwenku.com/question/p-osyvngye-zq.html" target="_blank" title="Yii URL模式問題"> Yii URL模式問題 </a> </li> <li> 17. <a href="http://hk.uwenku.com/question/p-rohcwvzv-hk.html" target="_blank" title="yii,開發和URL問題"> yii,開發和URL問題 </a> </li> <li> 18. <a href="http://hk.uwenku.com/question/p-nnpaviey-yh.html" target="_blank" title="添加標題標誌在YiiMailer"> 添加標題標誌在YiiMailer </a> </li> <li> 19. <a href="http://hk.uwenku.com/question/p-czieilix-rq.html" target="_blank" title="yii-bootstrap tbmenu標題"> yii-bootstrap tbmenu標題 </a> </li> <li> 20. <a href="http://hk.uwenku.com/question/p-yuuoywja-r.html" target="_blank" title="添加標題看中箱"> 添加標題看中箱 </a> </li> <li> 21. <a href="http://hk.uwenku.com/question/p-nbvyyeac-bcc.html" target="_blank" title="如何在Yii框架中添加子標籤onclick按鈕?"> 如何在Yii框架中添加子標籤onclick按鈕? </a> </li> <li> 22. <a href="http://hk.uwenku.com/question/p-fppxprxo-bcm.html" target="_blank" title="如何在Yii的GRIDVIEW中爲每個行添加TITLE標記"> 如何在Yii的GRIDVIEW中爲每個行添加TITLE標記 </a> </li> <li> 23. <a href="http://hk.uwenku.com/question/p-cutckbix-dd.html" target="_blank" title="在wordpress中爲圖片標題標籤添加標題"> 在wordpress中爲圖片標題標籤添加標題 </a> </li> <li> 24. <a href="http://hk.uwenku.com/question/p-aexnhqrw-bn.html" target="_blank" title="在Yii中向數據庫添加列"> 在Yii中向數據庫添加列 </a> </li> <li> 25. <a href="http://hk.uwenku.com/question/p-kowjdsxe-gu.html" target="_blank" title="如何在ajaxSubmitButton中添加效果yii"> 如何在ajaxSubmitButton中添加效果yii </a> </li> <li> 26. <a href="http://hk.uwenku.com/question/p-bzbwzqkz-mx.html" target="_blank" title="如何在yii中添加HTML CMenu"> 如何在yii中添加HTML CMenu </a> </li> <li> 27. <a href="http://hk.uwenku.com/question/p-rxagzvad-qo.html" target="_blank" title="將參數添加到URL中的Yii AJAX調用"> 將參數添加到URL中的Yii AJAX調用 </a> </li> <li> 28. <a href="http://hk.uwenku.com/question/p-hhlayxgg-oe.html" target="_blank" title="無標籤的URL添加"> 無標籤的URL添加 </a> </li> <li> 29. <a href="http://hk.uwenku.com/question/p-wwugykvk-gd.html" target="_blank" title="如何添加圖標+ URL"> 如何添加圖標+ URL </a> </li> <li> 30. <a href="http://hk.uwenku.com/question/p-qglfggem-bbk.html" target="_blank" title="在Yii中重寫URL"> 在Yii中重寫URL </a> </li> </ul> </div> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1575177025"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="padding-top-10"></div> </div> </div> <script type="text/javascript" src="http://img.uwenku.com/uwenku/script/side.js?t=1644592048261"></script> <script type="text/javascript" src="http://img.uwenku.com/uwenku/plugin/highlight/highlight.pack.js"></script> <link href="http://img.uwenku.com/uwenku/plugin/highlight/styles/docco.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $('pre').each(function(i, e) { hljs.highlightBlock(e, "<span class='indent'> </span>", false) }); </script> <div class="col-lg-3 col-md-4 col-sm-5"> <div id="rightTop"> <div class="row"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="5415218910" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="row sidebar panel panel-default"> <div class="panel-heading font-bold"> 最新問題 </div> <div class="m-b-sm m-t-sm clearfix"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-aqufpjkf-bdz.html" target="_blank" title="通過全局變量遍歷()字典"> 通過全局變量遍歷()字典 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-xlscueyg-bdt.html" target="_blank" title="爲什麼Web元素只在一個列表中的一個元素?"> 爲什麼Web元素只在一個列表中的一個元素? </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-nufpecky-bep.html" target="_blank" title="重定向與被迫小寫字母來識別文件名"> 重定向與被迫小寫字母來識別文件名 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-gojvozdy-beg.html" target="_blank" title="html-webpack-plugin如何與html-loader一起使用?"> html-webpack-plugin如何與html-loader一起使用? </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-qwlqkjgk-bgc.html" target="_blank" title="如何從gridview設置onClick圖像?"> 如何從gridview設置onClick圖像? </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-ynvpawpg-bev.html" target="_blank" title="實施ReactJS成角應用"> 實施ReactJS成角應用 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-bgyevfoe-bgm.html" target="_blank" title="如何編輯kendogrid的pageSize的使100在1-10這個改變顏色,點擊執行功能"> 如何編輯kendogrid的pageSize的使100在1-10這個改變顏色,點擊執行功能 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-fwspgjzb-bna.html" target="_blank" title="JavaFX 8:FXML的重用"> JavaFX 8:FXML的重用 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-xbmqmbpw-bmt.html" target="_blank" title="C中ICMPv6校驗和計算返回錯誤結果"> C中ICMPv6校驗和計算返回錯誤結果 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-bdvjbruj-bmn.html" target="_blank" title="Array.Filter和找不到錯誤角度4"> Array.Filter和找不到錯誤角度4 </a> </li> </ul> </div> </div> </div> <p class="article-nav-bar"></p> <div class="row sidebar article-nav"> <div class="row box_white visible-sm visible-md visible-lg margin-zero"> <div class="top"> <h3 class="title"><i class="glyphicon glyphicon-th-list"></i> 相關問題</h3> </div> <div class="article-relative-content"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-sbkgpuio-bn.html" target="_blank" title="Yii:向標題添加JavaScript"> Yii:向標題添加JavaScript </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-eatzfnbu-hn.html" target="_blank" title="如何在Yii中添加外部URL"> 如何在Yii中添加外部URL </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-khtkwtnn-up.html" target="_blank" title="在PHP中添加標題"> 在PHP中添加標題 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-kphyqqlg-bbd.html" target="_blank" title="在godoc中添加標題"> 在godoc中添加標題 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-ykgzsmll-bob.html" target="_blank" title="將URL添加到Photoswipe圖像標題"> 將URL添加到Photoswipe圖像標題 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-gwwhxpoo-bkd.html" target="_blank" title="如何在yii url中添加其他變量"> 如何在yii url中添加其他變量 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-yvasnpkz-gy.html" target="_blank" title="向ASP.NET MVC中的URL slugs添加標識和標題"> 向ASP.NET MVC中的URL slugs添加標識和標題 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-ocpcfhnc-bhr.html" target="_blank" title="在網站標題中添加徽標"> 在網站標題中添加徽標 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-hhuvcrit-nh.html" target="_blank" title="在標題中添加圖標"> 在標題中添加圖標 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-awzpmpml-kd.html" target="_blank" title="在UICollectionViewController標題上添加UISearchBar標題"> 在UICollectionViewController標題上添加UISearchBar標題 </a> </li> </ul> </div> </div> </div> </div> </div> </div> </div><!-- wrap end--> <!-- footer --> <footer id="footer"> <div class="bg-simple lt"> <div class="container"> <div class="row padder-v m-t"> <div class="col-xs-8"> <ul class="list-inline"> <li><a href="http://hk.uwenku.com/contact">聯系我們</a></li> <li>© 2020 HK.UWENKU.COM</li> <li><a target="_blank" href="https://beian.miit.gov.cn/">沪ICP备13005482号-4</a></li> <li><script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1280101193&web_id=1280101193"></script></li> <li><a href="http://www.uwenku.com/" target="_blank" title="优文库">简体中文</a></li> <li><a href="http://hk.uwenku.com/" target="_blank" title="優文庫">繁體中文</a></li> <li><a href="http://ru.uwenku.com/" target="_blank" title="поле вопросов и ответов">Русский</a></li> <li><a href="http://de.uwenku.com/" target="_blank" title="Frage - und - antwort - Park">Deutsch</a></li> <li><a href="http://es.uwenku.com/" target="_blank" title="Preguntas y respuestas">Español</a></li> <li><a href="http://hi.uwenku.com/" target="_blank" title="कार्यक्रम प्रश्न और उत्तर पार्क">हिन्दी</a></li> <li><a href="http://it.uwenku.com/" target="_blank" title="IL Programma di chiedere Park">Italiano</a></li> <li><a href="http://ja.uwenku.com/" target="_blank" title="プログラム問答園区">日本語</a></li> <li><a href="http://ko.uwenku.com/" target="_blank" title="프로그램 문답 단지">한국어</a></li> <li><a href="http://pl.uwenku.com/" target="_blank" title="program o park">Polski</a></li> <li><a href="http://tr.uwenku.com/" target="_blank" title="Program soru ve cevap parkı">Türkçe</a></li> <li><a href="http://vi.uwenku.com/" target="_blank" title="Đáp ứng viên">Tiếng Việt</a></li> <li><a href="http://fr.uwenku.com/" target="_blank" title="Programme interrogation Park">Française</a></li> </ul> </div> </div> </div> </div> </div> </footer> <!-- / footer --> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f78a970f17b19a79fc477a3378096f29"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>