Reputation: 227
I have a .htaccess file inside folder public
(root/public)
I would like to achieve the following transformations:
/index.php
-> /
index.php?site=siteName
-> /siteName/
/siteName/
or /siteName
-> serves as ?site=siteName
Here is my complete .htaccess file so far (with case 3 solved):
Allow from all
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ index.php?current=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?current=$1
Upvotes: 1
Views: 31
Reputation: 785186
You can use an additional rules for redirection of old URL to pretty URL and index.php
removal:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /index\.php\?current=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L,NE]
# remove index.php
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*)index\.php$ /$1 [L,R=302,NC,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?current=$1 [L,QSA]
Upvotes: 1