如何使mod_rewrite的SUP preSS处理更多的规则?规则、更多、mod_rewrite、SUP

由网友(故事里的风)分享简介:鉴于我目前的.htaccess文件,我将如何修改它来检查如/ src目录/酒吧/的额外的URL路径,并把它改写为/ 的'而不影响当前重写? 下面是原来的.htaccess文件:RewriteEngine叙述上的RewriteCond%{} REQUEST_FILENAME!-f的RewriteCond%{} REQU...

鉴于我目前的.htaccess文件,我将如何修改它来检查如/ src目录/酒吧/的额外的URL路径,并把它改写为/ 的'而不影响当前重写?

下面是原来的.htaccess文件:

  RewriteEngine叙述上

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d

重写规则^(。*)$的index.php?路径= $ 1 [L,QSA]
 

和这里是我最近尝试(不工作):

  RewriteEngine叙述上

重写规则^ / src目录/酒馆/(.*)$ / $ 1 [R]

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d

重写规则^(。*)$的index.php?路径= $ 1 [L,QSA]
 
死或生6 战斗更爽快玩法更多样 3月1日繁中版同步发售

编辑:下面是什么,我想完成一些例子:

新的附加规则:

 来源:http://www.mysite.com/src/pub/validfile.php
要:http://www.mysite.com/validfile.php

来源:http://www.mysite.com/src/pub/user/detail/testuser
要:http://www.mysite.com/user/detail/testuser
 

现有规则(已工作):

 来源:http://www.mysite.com/user/detail/testuser
要:http://www.mysite.com/index.php?route=user/detail/testuser
 

解决方案

我猜问题是,该URL被第二再次改写了第一条规则,然后重写。

要解决的是最后标志添加到第一个规则,像这样的:

 重写规则^ / src目录/酒馆/(.*)$ / $ 1 [R,L]
 

Given my current .htaccess file, how would I modify it to check for an additional URL path like '/src/pub/' and rewrite it to '/' without affecting the current rewrite?

Here's the original .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

and here's my recent attempt (which doesn't work):

RewriteEngine on

RewriteRule ^/src/pub/(.*)$ /$1 [R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

Edit: Here are some examples of what I want to accomplish:

New Additional Rule:

From:  http://www.mysite.com/src/pub/validfile.php
To:    http://www.mysite.com/validfile.php

From:  http://www.mysite.com/src/pub/user/detail/testuser
To:    http://www.mysite.com/user/detail/testuser

Existing Rule (already working):

From:  http://www.mysite.com/user/detail/testuser
To:    http://www.mysite.com/index.php?route=user/detail/testuser

解决方案

I'm guessing that the problem is that the URL is being rewritten by the first rule, and then rewritten again by the second.

The solution to that is to add the "last" flag to the first rule, like this:

RewriteRule ^/src/pub/(.*)$ /$1 [R,L]

阅读全文

相关推荐

最新文章