Reputation: 1242
I have a Subdirecotory in my webroot with some PHP files ( www/services/files.php ).
Current url: http://example.com/index.php?pageID=services/myservice
I would like it to be: http://example.com/services/myservice
My code:
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?pageID=/services$1 [L,QSA]
Upvotes: 0
Views: 40
Reputation: 24458
You want to make it appear as two subfolers so I would use this code for that type of URL structure. Using an .* would be too greedy.
This will allow you to use http://example.com/services/myservice
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?pageID=$1/$2 [L]
Upvotes: 1