Reputation: 173
I managed to put together .htaccess like this and it is working fine
RewriteRule ^$ /splash [L,R=301]
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.examle.com/$1 [R=301,QSA,L]
RewriteRule ^([A-Za-z0-9-]+)?$ /index.php?cat=$1 [L]
This redirects things like example.com/one to http://www.example.com/index.php?cat=one
However, I would like to add more functionality for my current project so that multiple variables get parsed. So for example:
example.com/category-one?another_variable=some_data&even_more=more_data, etc...
get parsed to
http://www.example.com/index.php?cat=category-one&another_variable=some_data&even_more=more_data
Also, is solution like this seo-friendly?
Upvotes: 3
Views: 151
Reputation: 286
try this RewriteRule ^mydir/([0-9]+)/(.*)$ myfile.php?var1=$1&var2=$2 [NC,L]
Upvotes: 0
Reputation: 785176
Add QSA
flag in last rule:
RewriteRule ^$ /splash [L,R=301]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^([a-z0-9-]+)/?$ /index.php?cat=$1 [L,NC,QSA]
QSA
(Query String Append) flag preserves existing query parameters while adding a new one.Upvotes: 1