mod-rewritehtaccess的寻呼系统寻呼、系统、mod、rewritehtaccess

由网友(沉舟侧畔过)分享简介:我有以下的code的正常工作重写规则^文章/([^/\.]+)/?$ articles.php?PID = $ 1 [L]的RewriteCond%{THE_REQUEST} ^ [AZ] {3,} \ S / +文章\ .PHP \ PID =([^ \ S&安培] +)?[NC]重写规则^ http://www...

我有以下的code的正常工作

 重写规则^文章/([^/.]+)/?$ articles.php?PID = $ 1 [L]
的RewriteCond%{THE_REQUEST} ^ [AZ] {3,}  S / +文章 .PHP  PID =([^  S&安培] +)?[NC]
重写规则^ http://www.mydomain.com/articles/%1? [R = 301,L]
 

现在的问题是,我有一个分页体制与我送另一个变量到该页面我的传呼系统,它看起来像这样

 &放大器; pageNum_getArticles = 1#1
 

我已经试着做以下,但会很困惑与哈希我觉得

 重写规则1 ^文章/([^/.]+)/?$ articles.php PID = $&放大器; pageNum_getArticles = $ 2 [L]
的RewriteCond%{THE_REQUEST} ^ [AZ] {3,}  S / +文章 .PHP  PID =([^  S&安培] +)?&安培; pageNum_getArticles =([^  S&功放;] +)[NC]
重写规则^ http://www.mydomain.com/articles/%1/%2? [R = 301,L]
 
运行命令大全 Windows运行命令大全

解决方案   

感谢您的信息。那么,有没有这个解决方案,或者我必须改变寻呼系统?

是的。

您有2套重写规则,这类工作在一起。第一条规则从没有任何查询字符串一个很好看的URL并在内部它重写PHP脚本。第二条规则取难看的PHP脚本URI和重定向到使用更好看的一个浏览器。第一组是正确的。但第二组使用相同的规则路由到该脚本。您需要创建另一组为分页,如 $ 2 不反向引用任何比赛。

尝试:

 #这里的第二场比赛--------------- v
?重写规则^文章/([^/.]+)/([^/.]+)/?$ articles.php PID = $ 1安培; pageNum_getArticles = $ 2 [L]
的RewriteCond%{THE_REQUEST} ^ [AZ] {3,}  S / +文章 .PHP  PID =([^  S&安培] +)?&安培; pageNum_getArticles =([^  S&功放;] +)[NC]
重写规则^ http://www.mydomain.com/articles/%1/%2? [R = 301,L]
 

请注意,如果你仍然想使用不使用分页的规则,你需要有非分页规则的在是带有分页。

此外,如果由于某种原因,你的页面不无网址片段工作,,如果该片段总是会一样的寻呼号码的,你可以将它添加到重定向结束。但你需要一个NE像FAA建议:

 重写规则^ http://www.mydomain.com/articles/%1/%2#%2? [R = 301,L,NE]
 

I have the following code which works fine

RewriteRule ^articles/([^/.]+)/?$ articles.php?pid=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+articles.php?pid=([^s&]+) [NC]
RewriteRule ^ http://www.mydomain.com/articles/%1? [R=301,L]

The problem is that I have a paging systen and I send another variable to that page for my paging system which looks like this

&pageNum_getArticles=1#1

I've already tried to do the following but gets confused with the hash I think

RewriteRule ^articles/([^/.]+)/?$ articles.php?pid=$1&pageNum_getArticles=$2 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+articles.php?pid=([^s&]+)&pageNum_getArticles=([^s&]+) [NC]
RewriteRule ^ http://www.mydomain.com/articles/%1/%2? [R=301,L]

解决方案

Thanks for the info. So is there a solution about this or I have to change the paging system?

Yes.

You have 2 sets of rewrite rules that sort of work together. The first rule takes a nice looking URL without any query strings and internally rewrites it to a php script. The second rule takes the ugly looking php script URI and redirects the browser to use the nicer looking one. The first set is correct. But the second set uses the same rule to route to the script. You need to create another grouping for your paging, as $2 doesn't backreference to any match.

Try:

# second match here---------------v
RewriteRule ^articles/([^/.]+)/([^/.]+)/?$ articles.php?pid=$1&pageNum_getArticles=$2 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+articles.php?pid=([^s&]+)&pageNum_getArticles=([^s&]+) [NC]
RewriteRule ^ http://www.mydomain.com/articles/%1/%2? [R=301,L]

Note that if you still want to use the rules that doesn't use paging, you need to have the non-paging rules after the ones with paging.

Additionally, if for some reason your paging doesn't work without the URL fragment, and if the fragment is always going to be the same as the paging number, you can just add it to the end of the redirect. But you'll need a NE like faa suggested:

RewriteRule ^ http://www.mydomain.com/articles/%1/%2#%2? [R=301,L,NE]

阅读全文

相关推荐

最新文章