簡體   English   中英

如何在.htaccess中重寫URL

[英]How to rewrite URL in .htaccess

大家好,我真的很感謝您,因為我從這里得到了幾種解決方案,希望我能為當前的問題找到解決方案。

網址是這樣的

www.xyz.com/c73-Graphic-Desgin?resultpage=2&aid=1

URL“ 73”“ 2”“ 1”中的值

我試圖將其重寫為.htaccess文件,如下所示,但它不起作用...

RewriteEngine On
RewriteRule ^c(.+)-(.+)-(.+)?resultpage=(.+)&aid=(.+)/?$ template.php?cid=$1&resultpage=$4&aid=$5&search=yes

請幫助我解決此問題,在此先感謝...

我的.htaccess文件

RewriteEngine On

#RewriteRule ^article/(.*)?$ article.php?aid=$1
#RewriteRule ^knowledge_base/([0-9]+)/(.*)?$ knowledge_base.php?p=$1&cid=$2
RewriteRule ^(.*)-article?$ article_detail.php?artid=$1

RewriteRule ^t([0-9]+)-(.+)/?$ temlate_detail.php?tid=$1

RewriteRule ^c([0-9]+)-sc([0-9]+)-(.+)/?$ templates.php?cid=$1&&scid=$2
RewriteRule ^c([0-9]{1,2})[a-zA-Z-]+?resultPage=([0-9]+)&aid=([0-9]+)$ templates.php?cid=$1


RewriteRule ^ac([0-9]+)-(.+)/?$ articles.php?cid=$1
RewriteRule ^p-(.*)$ pages.php?pageid=$1

#For PHP files:

RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(index|about|faq|freelancers|articles|contact|affiliates|login|forgot_password|change_password|cart|order_view|checkout|checkout_response|success|downloads|order_detail)(/.*)?$  $1.php
#php_value display_errors Off
#php_value upload_max_filesize 2000M
#php_value post_max_size 2000M
Options All -Indexes

您的正則表達式是錯誤的..您可以使用類似這樣的東西。

^c([0-9]{1,2})[a-zA-Z-]+?resultPage=([0-9]+)&aid=([0-9]+)$ //put here whatever u like to with $1, $2, $3 and $4

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM