2013-02-22 124 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