我的webroot中有一个子目录,包含一些PHP文件(www / services / files.php)。
当前网址:http://example.com/index.php?pageID=services/myservice
我希望它是:http://example.com/services/myservice
我的代码:
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?pageID=/services$1 [L,QSA]
答案 0 :(得分:1)
您希望将其显示为两个子幻灯片,因此我将此代码用于此类型的URL结构。使用。*会太贪心。
这样您就可以使用http://example.com/services/myservice
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?pageID=$1/$2 [L]