user3385375
user3385375

Reputation: 33

Mod Rewrite Htaccess for Fake sub Directories and directory

I am trying to create fake directories to redirect specific parameters to specific subdirectories as such: From: www.example.com/sys/signup To: www.example.com/system/ext.php?t=signup

Upvotes: 3

Views: 99

Answers (1)

Jon Lin
Jon Lin

Reputation: 143896

You need to redirect the browser from the URL with the query string to the one without, then you need to internally rewrite the URL back to the one with the query string:

RewriteEngine On

# redirect the browser to clean URL
RewriteCond %{THE_REQUEST} \ /+system/ext\.php\?t=([^&]+)
RewriteRule ^ /sys/%1? [L,R]

# internally rewrite back to the query string
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^sys/(.*)$ /system/ext.php?t=$1 [L,QSA]

Upvotes: 1

Related Questions