我在.htaccess文件中有一个重写规则,它创建了SEO友好的URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/?$ /pages/story.$1.php [L]
所以mydomain.com/pages/story.books.php将显示为mydomain.com/books
有没有办法在URL中传递其他参数?
mydomain.com/books?history
但是,附加参数是可选的,可能不完全相同。
我尝试了以下但是它违反了我的规则:
RewriteRule ^([^/.]+)/([a-zA-Z0-9-]+)/?$ /pages/story.$1.php?info=$2 [L]
我错过了什么?
答案 0 :(得分:0)
RewriteRule ^([A-za-z0-9_-]+)/?$ index.php?username=$1 [NC,L] # domain.com/post/name
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9]+)/?$ profil.php?id=$1&menu=$2 [NC,L] # domain.com/cat/post/id
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9]+)/([0-9]+)/?$ profil.php?id=$1&menu=$2&page=$3 [NC,L]