2013-02-22 122 views
0

我在這裏連接點時遇到了問題。在.htaccess中更改網址的步驟是否存在?這是我迄今爲止所擁有的。 moniquetrinidadjewelry.com/necklace/product.php?id=17 & PRODUCT_NAME =妖嬈%2520pearlhtaccess重寫更改url

和重寫

RewriteEngine On 
RewriteRule ^$necklace/([a-zA-Z]+)/([0-9]+)/$ product.php?id=$1&product_name=$2 

我的目標和我認爲是如上設置是moniquetrinidadjewelry的網址.com/necklace/id/product_name

我不完全確定問題來自哪裏。在地址欄中沒有任何更改,重新加載或重新開始瀏覽(即家庭項鍊等)

我是否缺少重要的東西或者是否跳過了不在htaccess本身內的步驟?

編輯:

# Use PHP5.3 Single php.ini as default 
AddHandler application/x-httpd-php53s .php 

# Always use www in the domain 
# Replace 'moniquetrinidadjewelry' with your domain name 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^([a-z.]+)?moniuetrinidadjewelry.com$ [NC] 
RewriteCond %{HTTP_HOST} !^www. [NC] 
RewriteRule .? http://www.%1moniquetrinidadjewelry.com%{REQUEST_URI} [R=301,L] 

RewriteEngine on 
RewriteCond %{QUERY_STRING} ^id=([0-9]+)&product_name=([a-zA-Z]+)$ 
RewriteRule product.php necklace/%1/%2/ 

# For security reasons, Option followsymlinks cannot be overridden. 
#Options -MultiViews +FollowSymlinks 
Options -MultiViews +SymLinksIfOwnerMatch 
RewriteEngine on 

# Always use www in the domain 
# Replace 'moniquetrinidadjewelry' with your domain name 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^([a-z.]+)?moniuetrinidadjewelry.com$ [NC] 
RewriteCond %{HTTP_HOST} !^www. [NC] 
RewriteRule .? http://www.%1moniquetrinidadjewelry.com%{REQUEST_URI} [R=301,L] 

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

RewriteCond %{HTTPS} !=on 
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] 

RewriteRule ^/?(.*/?)index\.(htm|html|php) /$1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php 

ErrorDocument 404/

<Files error_log> 
order allow,deny 
deny from all 
</Files> 

# Ultimate htaccess Blacklist 2 from Perishable Press 
# Deny domain access to spammers and other scumbags 
RewriteEngine on 
RewriteBase/
RewriteCond %{HTTP_USER_AGENT} ADSARobot|ah- ha|almaden|aktuelles|Anarchie|amzn_assoc|ASPSeek|ASSORT|ATHENS|Atomz|attach|attache|autoema ilspider|BackWeb|Bandit|BatchFTP|bdfetch|big.brother|BlackWidow|bmclient|Boston\  Project|BravoBrian\ SpiderEngine\ MarcoPolo|Bot\  mailto:[email protected]|Buddy|Bullseye|bumblebee|capture|CherryPicker|ChinaClaw|CICC|clip ping|Collector|Copier|Crescent|Crescent\ Internet\  ToolPak|Custo|cyberalert|DA$|Deweb|diagem|Digger|Digimarc|DIIbot|DISCo|DISCo\  Pump|DISCoFinder|Download\ Demon|Download\  Wonder|Downloader|Drip|DSurf15a|DTS.Agent|EasyDL|eCatch|ecollector|[email protected]\.net|Email\  Extractor|EirGrabber|email|EmailCollector|EmailSiphon|EmailWolf|Express\  WebPictures|ExtractorPro|EyeNetIE|FavOrg|fastlwspider|Favorites\  Sweeper|Fetch|FEZhead|FileHound|FlashGet\  WebWasher|FlickBot|fluffy|FrontPage|GalaxyBot|Generic|Getleft|GetRight|GetSmart|GetWeb!|Get WebPage|gigabaz|Girafabot|Go\!Zilla|Go!Zilla|Go-Ahead- Got-It|GornKer|gotit|Grabber|GrabNet|Grafula|Green\ Research|grub- client|Harvest|[email protected]|hloader|HMView|HomePageSearch|http\  generic|HTTrack|httpdown|httrack|ia_archiver|IBM_Planetwide|Image\ Stripper|Image\  Sucker|imagefetch|IncyWincy|Indy*Library|Indy\  Library|informant|Ingelin|InterGET|Internet\ Ninja|InternetLinkagent|Internet\  Ninja|InternetSeer\.com|Iria|Irvine|JBH*agent|JetCar|JOC|JOC\ Web\  Spider|JustView|KWebGet|Lachesis|larbin|LeechFTP|LexiBot|lftp|libwww|likse|Link|Link*Sleuth |LINKS\ ARoMATIZED|LinkWalker|LWP|lwp-trivial|Mag-Net|Magnet|Mac\ Finder|Mag-Net|Mass\  Downloader|MCspider|Memo|Microsoft.URL|MIDown\ tool|Mirror|Missigua\  Locator|Mister\  PiX|MMMtoCrawl\/UrlDispatcherLLL|^Mozilla$|Mozilla.*Indy|Mozilla.*NEWT|Mozilla*MSIECrawler| MS\  FrontPage*|MSFrontPage|MSIECrawler|MSProxy|multithreaddb|nationaldirectory|Navroad|NearSite |NetAnts|NetCarta|NetMechanic|netprospector|NetResearchServer|NetSpider|Net\  Vampire|NetZIP|NetZip\ Downloader|NetZippy|NEWT|NICErsPRO|Ninja|NPBot|Octopus|Offline\   Explorer|Offline\ Navigator|OpaL|Openfind|OpenTextSiteCrawler|OrangeBot|PageGrabber|Papa\ Foto|PackRat|pavuk|pcBrowser|PersonaPilot|Ping|PingALink|Pockey|Proxy|psbot|PSurf|puf|Pump|  PushSite|QRVA|RealDownload|Reaper|Recorder|ReGet|replacer|RepoMonkey|Robozilla|Rover|RPT- HTTPClient|Rsync|Scooter|SearchExpress|searchhippo|searchterms\.it|Second\ Street\  Research|Seeker|Shai|Siphon|sitecheck|sitecheck.internetseer.com|SiteSnagger|SlySearch|Smar  tDownload|snagger|Snake|SpaceBison|Spegla|SpiderBot|sproose|SqWorm|Stripper|Sucker|SuperBot |SuperHTTP|Surfbot|SurfWalker|Szukacz|tAkeOut|tarspider|Teleport\  Pro|Templeton|TrueRobot|TV33_Mercator|UIowaCrawler|UtilMind|URLSpiderPro|URL_Spider_Pro|Vac uum|vagabondo|vayala|visibilitygap|VoidEYE|vspider|Web\ Downloader|w3mir|Web\ Data\  Extractor|Web\ Image\ Collector|Web\ Sucker|Wweb|WebAuto|WebBandit|web\.by \.mail|Webclipping|webcollage|webcollector|WebCopier|[email protected]|webdevil|webdownloader|We bdup|WebEMailExtrac|WebFetch|WebGo\  IS|WebHook|Webinator|WebLeacher|WEBMASTERS|WebMiner|WebMirror|webmole|WebReaper|WebSauger|W ebsite|Website\ eXtractor|Website\  Quester|WebSnake|Webster|WebStripper|websucker|webvac|webwalk|webweasel|WebWhacker|WebZIP|W get|Whacker|whizbang|WhosTalking|Widow|WISEbot|WWWOFFLE|x-Tractor|^Xaldon\  WebSpider|WUMPUS|Xenu|XGET|Zeus.*Webster|Zeus [NC] 
RewriteRule ^.* - [F,L] 

回答

0

如果我理解正確的話,你必須首先拍攝在RewriteCond查詢字符串部分,然後使用在RewriteRule

RewriteCond %{QUERY_STRING} ^id=([0-9]+)&product_name=([a-zA-Z]+)$ 
RewriteRule product.php necklace/%1/%2/ [R,L] 

此規則將觸發,當有URL product.php?id=17&product_name=enchanting%2520pearl並將其重寫爲necklace/17/enchanting%2520pearl。客戶端被重定向,瀏覽器欄應顯示新的URL。

如果你希望它倒過來,這一次應該工作

RewriteRule necklace/([0-9]+)/([a-zA-Z]+) product.php?id=$1&product_name=$2 
+0

嗨奧拉夫感謝您的快速反應。我想我明白你在說什麼,但我似乎還不知道。我已經嘗試將產品名稱更改爲product_name(a-zA-Z ...),並切換ID,因爲ID是數字,我認爲這可能是問題,但沒有。如果這是成功的http://www.moniquetrinidadjewelry.com/necklace/id/product_name的地址實際上應該帶我到原來的正確?它根本沒有任何影響。我已經在上面添加了我的總體訪問權限,以包含您引用的內容。 – 2013-02-22 18:19:45

+0

@HireLogo我修正了'id'和'product_name'並添加了一個重定向'R'標誌。我試着解釋這裏發生的事情。如果這不是你想要的,請告訴我。 – 2013-02-22 22:43:55

+0

嗨奧拉夫再次感謝......這正是我想要做的,但我沒有看到任何事情發生。我已經將它包含在我的.htaccess中,沒有任何反應。我覺得我從等式中遺漏了一些東西,因爲我之前的任何嘗試都沒有看到地址上的變化。 – 2013-02-23 00:48:52