讨厌问这个问题,但我一直在桌子上敲了一会儿,似乎无法得到它。我正在使用ExpressionEngine,我正在使用mod_rewrite从我的所有URL中删除index.php。这很好。另外,我想要将任何myurl.com/adwords/(anything)重写为myurl.com/(anything)。我的正则表达式和htaccess技能很弱。这是我在.htaccess中所拥有的:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/adwords/(.*)$
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
所以我想我说的是以/ adwords /(某事物)结尾的任何东西,抓住某些东西,然后通过$ 1将它附加到index.php的末尾。我猜这很简单。谢谢!
答案 0 :(得分:3)
您正在寻找的规则可能只是
RewriteRule ^adwords/(.*)$ index.php/$1 [L]
没有重写条件,但我想知道......你真的想把http://myurl.com/adwords/foo重写为http://myurl.com/index.php/foo,而不是http://myurl.com/index.php?a=foo吗?
如果您还想将http://myurl.com/baa/adwords/foo重写为http://myurl.com/baa/index.php/foo,则必须省略^:
RewriteRule adwords/(.*)$ index.php/$1 [L]
顺便说一句,您可以在此处测试大部分重写规则:http://htaccess.madewithlove.be/