Regex htaccess单页重写规则

Regex htaccess单页重写规则,regex,apache,.htaccess,Regex,Apache,.htaccess,我想改变: domain/link to domain/index.php?q=link 及 使用此.htaccess文件: RewriteEngine On RewriteRule ^([a-zA-Z-]+)$ index.php?q=$1 [L] RewriteRule ^notice/([0-9]+)/([A-Za-z0-9_-]+)$ index.php?q=notice&date=$1&title=$2 [L] 如果我进入domain/link或domain/lin

我想改变:

domain/link to domain/index.php?q=link

使用此.htaccess文件:

RewriteEngine On
RewriteRule ^([a-zA-Z-]+)$ index.php?q=$1 [L]
RewriteRule ^notice/([0-9]+)/([A-Za-z0-9_-]+)$ index.php?q=notice&date=$1&title=$2 [L]
如果我进入
domain/link或domain/link2
,进展顺利,但如果我尝试进入
domain/notice/20151212/title-with-a
,我不能,因为它无法获取CSS、图像、JS文件(当文件位于
domain/notice/20151212/JS/theme.JS
中时,尝试获取
domain/notice/20151212/JS/theme.JS
)但我可以通过URL毫无问题地进入:

domain/index.php?q=notice&date=20151212&title=Title-with-a
我做错了什么

我检查了这个正则表达式,我认为htaccess文件是正确的

谢谢。

试着这样做

RewriteEngine On
RewriteRule ^notice/([^/]+)/([^/]+)/$ index.php?q=notice&date=$1&title=$2 [L]
RewriteRule ^([a-zA-Z-]+)$ index.php?q=$1 [L]
试着像这里一样恢复顺序

RewriteEngine On
RewriteRule ^notice/([0-9]+)/([A-Za-z0-9_-]+)$ index.php?q=notice&date=$1&title=$2 [L]
RewriteRule ^([a-zA-Z-]+)$ index.php?q=$1 [L]
编辑 在第二行末尾添加[L]并尝试我的url,它可以工作

如果您不想在url的末尾使用/,请使用此

RewriteRule ^notice/([^/]+)/([^/]+) notice.php?q=notice&date=$1&title=$2 [L]

谢谢,但更改顺序后,我得到了相同的结果,我认为第一个结果(不是有效规则)无法解决我的问题简单的解决方案:在文档的开头添加一个base标记,谢谢,我曾尝试将RewriteBase放在.htacces上,但我忽略了这一点
RewriteRule ^notice/([^/]+)/([^/]+) notice.php?q=notice&date=$1&title=$2 [L]